[comp.text] troff macro problem

lll@pollux.UUCP (Laurence Leff) (11/17/88)

I am having trouble making the correct page number appear
on a list of figures, when the figure caption appears inside
the ms macros KS-KE pair of KF KE pair.

I have made the necessary additions and modifications to the ms
macros to print out stuff for thesis.
ONe of the theings I would like to do would be to output the
table of figures and table of tables.  This is done by the
use of diversinos,  each time a figure caption is generated,
an addition is made containing the figure number, the title
of the figure and lastly the page number on which the figure appears.

Most of the time, this figure caption macro is called inside
a KS, KE or KF KE pair.  Unfortunately, the page number that
appears is the one where the macro was called and not the
one that it appeared on.  
If there wasn't enough space for the KS KE to print on the same
page, then the page number is off by one.

I have reproduced the problem using the KS, KE macros given
in the nroff/troff tutorial.  
The last line should indicate that the figure appeared on page two.

ON the line in FG, after the comment (tm help), I Have tried various
counts of backslashes both before the n and before the t
to no avail.

.de hd
.tl "-%-
..
.wh 0 hd
.de LP
.sp 1
..
.de FG
'ev 2
'br
'da XZ
.\" 'tm help
\\$1 page: \\n%

'da
'ev
..
.de KS
.br
.ev 1
.fi
.di XX
..
.de KE
.br
.di
.ne \\n(.t
.\" .if \\n(dn>=\\n(.t .bp
.nf
.XX
.ev
..
test1
.sp 1i
.KS
.FG "Figure 1"
.sp 10i
Figure 1
.KE
.sp 1i
test 2
.bp
.tl "this is XZ:"
.ev 2
.XZ

bb@wjh12.harvard.edu (Brent Byer) (11/18/88)

In article <13138@pollux.UUCP> lll@pollux.UUCP (Laurence Leff) writes:
>
>I am having trouble making the correct page number appear
>on a list of figures, when the figure caption appears inside
>the ms macros KS-KE pair of KF KE pair.
>
Below is an amended copy of your original .FG macro which does the trick.

 .de FG
 .ie !\(ts\\n(.z\(ts\(ts \{\
 .\" arrive here iff we are storing into the 'keep' diversion
 .\"   that is, the current diversion name is non-null, so we put a copy
 .\"   of ourself into the diversion, such that we get another chance upon
 .\"   the re-read of the diversion (on the final destination page)
 \!.FG "\\$1"
 . \}
 .el \{\
 .\" arrive here iff we are reading back from the 'keep' diversion, and,
 .\" hence, we know what page we will land upon
 'ev 2
 'br
 'da XZ
 .\" 'tm help
 \\$1 page: \\n%
 
 'da
 'ev
 . \}
 ..

	Brent Byer
	Textware Intl.
	PO 14 - Harvard Sq
	Cambridge, MA 02238
	  (617) uni-text     att!ihesa!textware!brent

iau@ukc.ac.uk (I.A.Utting) (11/18/88)

In article <13138@pollux.UUCP> lll@pollux.UUCP (Laurence Leff) writes:
>I am having trouble making the correct page number appear
>on a list of figures, when the figure caption appears inside
>the ms macros KS-KE pair of KF KE pair.

I have always had great success using these macros, which came off the net
back in the dawn of time. I've no documentation other than these comments.

----------cut here---------
.\"     Do a command OUtside of diversions, or for EVery diversion level.
.\"     (Use OU and EV for macro calls, Ou and Ev for bare nroff commands.)
.\"
.\"	Uparrow is used instead of backslash for the escape character
.\"	so that you needn't count backslashes.  Just use one uparrow where
.\"	you would want a backslash in the final command.
.\"
.\"     Examples:
.\"
.\"	".Ev .cs R 25" can be used in a display to set constant spacing
.\"     mode such that it will again be in effect whenever the display
.\"     is pulled back in from the diversion.
.\"
.\"	If number register P contains the current page number,
.\"	.Ou .tm Current page number is ^nP
.\"	will dump the correct page number to fd 2 regardless of how many
.\"	levels deep in diversion you are, and how many pages your floating
.\"	display floated across.
.\"
.\"	Written by:
.\"		Larry Wall
.\"		{allegra,burdvax,cbosgd,hplabs,ihnp4,sdcsvax}!sdcrdcf!lwall
.de Ou
.ie '\\n(.z'' \\{\\
.di ??
\!\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
.di
.ec ^
.??
.ec
.rm ??
'br\\}
.el \\{\\
\!.ie '\\\\n(.z'' \\\\{\\\\
\!.ec ^
\!\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
\!.ec
\!'br\\\\}
\!.el \\\\{\\\\
\!.Ou "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\!'br\\\\}
'br\\}
..
.de Ev
.di ??
\!\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
.di
.ec ^
.??
.ec
.rm ??
.if !'\\n(.z'' \\{\\
\!.ie '\\\\n(.z'' \\\\{\\\\
\!.ec ^
\!\\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
\!.ec
\!'br\\\\}
\!.el \\\\{\\\\
\!.Ev "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\!'br\\\\}
'br\\}
..
.\"
.\"	Same as above, but quoting is different
.\"
.de OU
.ie '\\n(.z'' \\{\\
.di ??
\!\\$1 "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
.di
.ec ^
.??
.ec
.rm ??
'br\\}
.el \\{\\
\!.ie '\\\\n(.z'' \\\\{\\\\
\!.ec ^
\!\\$1 "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\!.ec
\!'br\\\\}
\!.el \\\\{\\\\
\!.OU "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\!'br\\\\}
'br\\}
..
.de EV
.di ??
\!\\$1 "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
.di
.ec ^
.??
.ec
.rm ??
.if !'\\n(.z'' \\{\\
\!.ie '\\\\n(.z'' \\\\{\\\\
\!.ec ^
\!\\$1 "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\!.ec
\!'br\\\\}
\!.el \\\\{\\\\
\!.EV "\\$1" "\\$2" "\\$3" "\\$4" "\\$5" "\\$6" "\\$7" "\\$8" "\\$9"
\!'br\\\\}
'br\\}
..