groff
[Top][All Lists]
Advanced

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

Re: [Groff] automatic equation numbering


From: Ted Harding
Subject: Re: [Groff] automatic equation numbering
Date: Mon, 17 Mar 2014 17:12:05 -0000 (GMT)

On 17-Mar-2014 13:56:56 Anton Shterenlikht wrote:
>>From address@hidden Sun Mar 16 01:01:31 2014
>>
>>Here is a suggestion (it's a technique I use systematically for
>>the purpose you describe). The following is in the context of ms
>>macros, though the same (or possibly a slight variant) should work
>>for other macro sets.
>>
>>**I first define an equation numbering and description system:
>>
>>.nr EQno 0 1
>>.ds EQnxt \Z'\h'0.5m'[\\n+[EQno]\\$1]'
>>.ds EQnow \Z'\h'0.5m'[\\n[EQno]\\$1]'
>>.ds EQthing \Z'\h'0.5m'[\\$1]'
>>
>>These define an auto-incrementing equation number \n[EQno],
>>so that, for instance (wsaqy we have already got up to equation [4],
>>
>>.EQ \*[EQnxt]
>>phi ( x ) ~=~ exp( - half x sup 2 ) / sqrt{2 pi}
>>.EN
>>.ds EQnormdist \*[EQnow]
>>
>>Then the above equation will have its equation number (5) displayed
>>to the right as " [5]", since the "\n+[EQno]" when "\n[EQnxt]" is
>>read will first increment \n[EQno] from 4 to 5.
> 
> I cannot check with a graphical output right now,
> but rendered with ascii, I get strange results:
> 
> $ cat bend.1
> .nr EQno 0 1
> .ds EQnxt \Z'\h'0.5m'(\\n+[EQno]\\$1)'
> .ds EQnow \Z'\h'0.5m'(\\n[EQno]\\$1)'
> .ds EQthing \Z'\h'0.5m'[\\$1]'
> .NH 1
> Some section
> .PP
> Eqn. \*[mumu] shows that ...
> .EQ \*[EQnxt]
> phi ( x ) ~=~ exp( - half x sup 2 ) / sqrt{2 pi}
> .EN
> .ds mumu \*[EQnow]
> .ds mumua \*[EQnow a]
> .ds mumub \*[EQnow b]
> .PP
> Eqns. 2"] ...
> $ /usr/local/bin/groff -e -ms -Tascii bend.1 | head -n 15
> bend.1:62: warning: can't find special character `*p'
> bend.1:69: warning: can't find special character `sqrt'
> bend.1:98: warning: can't find special character `sqrtex'
> bend.1:107: warning: can't find special character `*f'
> 
> 
> 
> 
> 
> 
> 1.  Some section
> 
>      Eqn.  shows that ...
> 
>                        (x)=exp(-_x2)/2                      (1)
> 
> 
>      Eqns. ,1(...
> $
> 
> The last line of output is wrong.
> It should've read "Eqns. (1a), (1b) ...".
> What am I missing?
> 
> Also, how exactly do I run groff twice
> to resolve the first, forward-looking reference?
> Should I take care myself that some cross-referencing
> information is saved to files?
> Or is this done automatically with some
> command line options with ms?
> 
> Many thanks
> Anton

Apologies -- I had left a little elephant trap in the definitions!
Remove the \Z'...' from the definitions of EQnow, and then it should
be OK (the effect of \Z'...' is to cause "..." to be printed, followed
by a return to where it was previously, i.e. as if it had zero width).
So in your output (and it would be similar in PS output), your
"\*[mumub]" will  over=print your "\*[mumua]". With, instead:

$ cat bend.1
.nr EQno 0 1
.ds EQnxt \Z'\h'0.5m'(\\n+[EQno]\\$1)'
.ds EQnow \h'0.5m'(\\n[EQno]\\$1)
.ds EQthing \h'0.5m'[\\$1]
.\".ds EQnow \Z'\h'0.5m'(\\n[EQno]\\$1)'
.\".ds EQthing \Z'\h'0.5m'[\\$1]'
.NH 1
Some section
.PP
Eqn. \*[mumu] shows that ...
.EQ \*[EQnxt]
phi ( x ) ~=~ exp( - half x sup 2 ) / sqrt{2 pi}
.EN
.ds mumu \*[EQnow]
.ds mumua \*[EQnow a]
.ds mumub \*[EQnow b]
.PP
Eqns. \*[mumua], \*[mumub] ...

followed by:

groff -e -ms -Tascii bend.1 | head -n 15

I get (on the terminal):

1.  Some section

     Eqn.  shows that ...

                       (x)=exp(-2x2)/2                      (1)


     Eqns. (1a), (1b) ...


The reason for the "can't find special character" warnings is that
the font-set for -Tascii is simply the ASCII character set, which
does not include Greek characters or mathematical symbols, namely
in the case of your example

  special character `*p'         Greek pi
  special character `sqrt'       Square root sign
  special character `sqrtex'     Square root extension [1]
  special character `*f'         Greek phi

[1]: The square root extension is a line which can be attached to
the top of the vertical part of the square root sign to make it taller
(i.e. to match a tall expression to the right of it).

Hoping this helps,
Ted.

-------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Date: 17-Mar-2014  Time: 17:12:02
This message was sent by XFMail
-------------------------------------------------


reply via email to

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