[comp.text] figure number generator for -me

mungo@strath-cs.UUCP (03/10/87)

(If you have seen these macros before, I apologise. We had line
problems a while ago and I didn't think the article escaped
our site. The question I would like answered is given later on,
so please don't wade through the following first !)

I have written some macros for use with the -me package.
These macros automatically associate a figure NUMBER with a
description STRING, so that the user need not re-number his figures
should he insert or delete one in the middle of a run of figures.
The macros also reserve the page(s) following a declaration of a new
figure for that figure (one figure per page), and on that figure page
they centre a line at the bottom of the page with the figure's NUMBER.
(Personally I don't like to keep referring to the back of a document
to see a figure - I'd rather have it just after the first time it is
referred to. Also, I don't like figure pages without page numbers: a
quick check through a document for consecutive pages won't reveal that
a figure drawing is missing. Hence these macros print the standard
headers and footers on the figure page, which gives minor irritation
when I overprint my MacIntosh drawings on the already-printed figure
page.)
To use these macros, do something like:
	see the text in figure
	.FN "figure one"
	or in figure
	.FN two
	or even in figure
	.FN three.part.two .
The first parameter to the macro FN is the FIGURE IDENTIFIER:
usually a meaningful name which you want to use (i.e. use a name such
as "house.elevation" rather than "one").
Just like the italics command ".i", the second parameter to FN is
placed immediately after the figure NUMBER which is output.
To reset the figure numbers back to 1, call FN with no parameters.
The internal working of the set of macros append a string like:
	if $1 == house.elevation then S := 1
to another macro, so though you can reset the numbers generated to 1,
the name sticks - use it twice and you get the same value.
(the following will print the same figure number for house.elevation:
	.FN house.elevation
	.FN
	.FN house.elevation
)

I wrote the macros for my thesis.
I use the document-preparation facilities on our VAX to generate the
text on a laser printer (final copy) and then use MacDraw to print my
MacDraw figures onto the already-printed pages.
My macros are given below and are freely available to anyone who cares
to use them: copy and distribute at will.
They will currently only work with -me, and please note that the
macro $H referenced in the -me header macro is defined in these
macros.

QUESTION:

There's just one small point which I would be grateful for any help
on. The macros print extra spaces such as "figure   1." on the first
calling to a new figure reference, yet subsequent callings to the same
reference gives "figure 1." - I have tried to correct this but to no
avail.
Any help with the macros would be most gratefully received.
Also other improvements would be nice too.

Thanks,
	Mungo Henning

.\" Now the figure number stuff
.de *F
.rm *S
..
.de FN
.if !\\n(.$ \{\
.if \\n(*H<\\n(Fn .bp
.nr Fn 0 1
.nr *H 0 1
\}
.if \\n(.$ \{\
.*F \\$1
.if ^\\*(*S^^ \{\
'rr Fs
'nr Fs (\\n(Fn+1)
'ie ^\\*(CY^^ \{\
'am *F
'if ^\\$1^\\\\$1^ .ds *S "\\n(Fs
\\..
\}
'el \{\
'am *F
'if ^\\$1^\\\\$1^ .ds *S "\\*(CY.\\n(Fs
\\..
\}
'nr Fn (\\n(Fn+1)
'*F \\$1
\}
\\&\\*(*S\c
'if \\n(*D \\ {\\$1}
'if \\n(.$=2 \\&\\$2
\}
..
.de $H
.if \\n(*H<\\n(Fn \{\
.rs
.sp (\\n(.tu-1v)
.nr *H (\\n(*H+1)
.ie ^\\*(CY^^ .tl ''Figure \\n(*H''
.el .tl ''Figure \\*(CY.\\n(*H''
\}
..
.FN
-- 
ARPA:	mungo%cs.strath.ac.uk@ucl-cs.arpa, mungo@cs.strath.ac.uk
UUCP:	mungo@strath-cs.uucp, ...!seismo!mcvax!ukc!strath-cs!mungo
JANET:	mungo@uk.ac.strath.cs