groff
[Top][All Lists]
Advanced

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

[Groff] WARNING: tbl with auto-incrementing registers!


From: Ted Harding
Subject: [Groff] WARNING: tbl with auto-incrementing registers!
Date: Tue, 19 Feb 2008 13:44:51 -0000 (GMT)

Hi Folks,
I have just stumbled on a nasty little trap.

Do not use auto-incrementing number registers in tables!!

Example (two versions):

A:

.nr EQno 0 1
.LP
\n+[EQno] \n+[EQno]

Output:
1 2

===================

B:

.nr EQno 0 1
.LP
.TS
tab(#);
l l.
\n+[EQno]#\n+[EQno]
.TE

Output:
3  4

===================

Reason: In the output of tbl, one finds 
lines like:

.nr 3w0 \n[3w0]>?\w\[tbl]\n+[EQno]\[tbl]
.nr 3w1 \n[3w1]>?\w\[tbl]\n+[EQno]\[tbl]
...
\&\h'|\n[3cl0]u'\n+[EQno]\h'|\n[3cl1]u'\n+[EQno]

The first two lines calculate some widths -- and at
the same time increment the register \n[EQno], first to 1,
then to 2; and then the third line (which does the printing)
increments it to 3 and then to 4!

Background:
For layout reasons, I wanted to put some numbered
equations into a table, with auto-incrementing equation
numbers, on the lines of

.TS
tab(#);
l l l.
What it's about#$the equation$#\n+[EQno]
...(more of the same)
.TE

... with the results described above!

I don't see any way of working round this, given the way
'tbl' works, except to use customised fixed-value registers
in this type of context. For example:

.nr tblEQno1 \n+[EQno]
.nr tblEQno2 \n+[EQno]
.nr tblEQno3 \n+[EQno]
.TS
tab(#);
l l l.
About 1#$eqn 1$#\n[tblEQno1]
About 2#$eqn 2$#\n[tblEQno2]
About 3#$eqn 3$#\n[tblEQno3]

.TE

Then \n[EQno] has been auto-incremented (in the background)
by 3, ready for its next normal (not-in-table) invocation.

Comments welcome!
Best wishes to all,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 19-Feb-08                                       Time: 13:44:47
------------------------------ XFMail ------------------------------




reply via email to

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