Article View: net.text
Article #1223Re: nroff -ms figure numbering
From: Avi Naiman
Date: Fri, 07 Nov 1986 21:06
Date: Fri, 07 Nov 1986 21:06
151 lines
4862 bytes
4862 bytes
> I use floating keeps to keep the figures together, but keep
> losing track of what number I'm on. I'm also screwed anytime I add
> or delete a figure. Does someone out there have a nifty little
> macro to automatically number my figures for me?
Here are some string definitions that use *roff's autoincrement
capability for number registers. Fr is used for referencing
the figure in your text, and Fn for numbering the figure in a
caption. [Er and En can be used to reference the same figure
a number of times before autoincrementing to the next number.]
.\"--------------------
.\" Figure Referencing and Numbering
.ds Fr \\n+(Fr
.ds Er \\n(Fr
.ds Fn \\n+(Fn
.ds En \\n(Fn
.\"--------------------
For example:
See figure \*(Fr.
This is the figure \*(Fn.
Here are more elaborate versions of the same strings, allowing you
to incorporate a section or chapter number into the figure number.
The section number can be similary autoincremented in a New Section
Macro.
.\"--------------------
.\" Figure Referencing and Numbering
.ds Fr \\n(Cn\.\\n+(Fr
.ds Er \\n(Cn\.\\n(Fr
.ds Fn \\n(Cn\.\\n+(Fn
.ds En \\n(Cn\.\\n(Fn
.\"--------------------
Finally, the two macros Fs (Figure start) and Fe (Figure end) allow
you to use a consistent graphic design for your figures.
Fs takes two arguments: the first specifies the amount of white space
(in inches) to leave for cutting and pasting in a figure (this can be
ommitted if your figure is generated from within *roff, e.g. a pic figure);
the second is the number to use for labeling the figure at the beginning
of the caption. These macros have been developed for use with the ms
macro package and use floating keeps to push the figure to the next page
if there isn't enough room on the current one.
The graphic design involves rules before and after the figure,
an indented, shortened paragraph for the caption (using a reduced
point size), and appropriate white space between the elements.
.\"--------------------
.\" Figure Start
.de Fs
.KF
.if t .sp 0.25i
.if n .sp 2
.if t \s14\h'|0u'\l'6i\(ul'\s0
.if n \s14\h'|0u'\l'6i\(ul'\s0
.in +0.5i
.ll -0.5i
.nr LL -0.5i
.if t .ps -2
.if t .nr PS -2
.if t .vs -6
.if t .nr VS -6
.if t .sp \\$1i
.if n .sp 6u*\\$1
.if t .IP "Figure \\$2\." 0.75i
.if n .IP "Figure \\$2\." 14n
..
.\"--------------------
.\" Figure End
.de Fe
.br
.RT
.in -0.5i
.ll +0.5i
.nr LL +0.5i
.if t .ps +2
.if t .nr PS +2
.if t .vs +6
.if t .nr VS +6
.if t \s14\h'|0u'\l'6i\(ul'\s0
.if n \s14\h'|0u'\l'6i\(ul'\s0
.if t .sp 0.25i
.if n .sp 2
.KE
..
For example, the following text (with the macros above inserted)
run through nroff -ms produces the result below:
.nr Cn 1
.nr Fr 0 1
.nr Fn 0 1
.PP
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is text. This is text.
Figure \*(Fr is a figure.
.Fs 2 \*(Fn
This is the figure.
.Fe
.PP
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is text. This is text.
This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. Figure 1.1 is a figure.
____________________________________________________________
Figure 1.1. This is the figure.
____________________________________________________________
This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text. This is text. This is text. This is text. This is
text.
Yours to enjoy,
Avi Naiman
Technical Details
Message-ID:
<700002@hpcehfe.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!rutgers!sri-spam!sri-unix!hplabs!hpcea!hpcehfe!aviReferences:
<1278@loral.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!rutgers!sri-spam!sri-unix!hplabs!hpcea!hpcehfe!avi From: avi@hpcehfe.HP.COM (Avi Naiman) Newsgroups: net.text Subject: Re: nroff -ms figure numbering Message-ID: <700002@hpcehfe.HP.COM> Date: Fri, 7-Nov-86 16:06:33 EST Article-I.D.: hpcehfe.700002 Posted: Fri Nov 7 16:06:33 1986 Date-Received: Sun, 9-Nov-86 03:34:16 EST References: <1278@loral.UUCP> Organization: Corporate Human Factors Engineering Lines: 151