groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Typesetting arbitrary fractions?


From: Dave Kemper
Subject: Re: [Groff] Typesetting arbitrary fractions?
Date: Tue, 17 Sep 2013 03:36:58 -0500

Back in the dark ages of 2005, Ted posted a useful little macro for
rendering fractions:

> .de frac
> .nr n0 \\n[.s]
> .nr n1 \\n[n0]*6/10
> .nr dn (\\n[n0]-\\n[n1])*8/10
> \v'-\\n[dn]p'\s[\\n[n1]]\\$1\s0\v'\\n[dn]p'\[f/]\s[\\n[n1]]\\$2\s0
> ..

I had incorporated this, with some tweaks, into my own macro set, to
which I've added sporadically over a few years.

Another macro I added to my toolbox was one I wrote to do some processing
around the .PSPIC macro (mostly to correctly align the baselines of text
that follows it).  This involved creating a diversion and using groff's
built-in \n[dn] register to find its size.

With the two examples above in such proximity, the problem is readily
apparent: each macro uses the dn register in a different way.  In my case,
the problem was anything but readily apparent: by the time I added the
pic-related macro, .frac had been in my toolbox and working flawlessly for
quite some time, so I remembered no details of it.  And the two macros did
vastly different things, so were nowhere near each other in my macro file.

Thus separated by time and space, the presence of duelling dn's went
undetected for some time, until a few days ago when a bizarre bug popped
up in elements that had previously appeared to work.

I post this merely as a cautionary tale: I'm sure I'm not the only one
who finds useful macros in the groff email list archives, and if anyone
else finds and uses Ted's .frac, changing the "dn" to something groff
hasn't already defined for another purpose might spare you the hours it
took me to find this obscure problem.

(This is in no way meant to take Ted to task for something he probably
tossed together quickly and only as an illustrative example eight years
ago.  And he did end his email with "So that's the basics of doing it, but
clearly you have to watch out for detail depending on the environment,"
a warning I should have taken more to heart.  :-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]