groff
[Top][All Lists]
Advanced

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

Re: [Groff] problem with nested diversions


From: Tadziu Hoffmann
Subject: Re: [Groff] problem with nested diversions
Date: Tue, 19 Aug 2008 17:59:23 +0200
User-agent: Mutt/1.5.16 (2007-06-09)

> > The calls for the macro containing the nested diversion seem
> > out of place relative to the text flow.

> This appears to be a limitation of `\!' which is present in
> traditional troff also.  It seems that a call to the stuff
> embedded with `\!' is triggered by a newline in a diversion
> and not the position of `\!' in the data stream.

Yes, "replaying" a diversion is not much different from
expanding a macro, i.e., the contents of the diversion are
inserted into the processing stream.  In case of a diversion,
however, the input lines have already been assembled when the
diversion was first read, and usually bear no simple relation
to the lines of the original source text.  In troff, macro
invocations are line-oriented (they occur "between" input
lines), and an embedded macro call appears to be inserted into
the diversion prior to the line (in the diversion) containing
the place where "\!" was encountered in the original input.


> Finally, I don't think at all that my solution is ugly :-)

Torture test: does it work with tables? ;-|  (It seems to
have trouble with the rules, but it may be an interesting
intellectual exercise getting it to work.)


> In case a solution is possible with .de you should prefer this
> -- working on unformatted stuff is always easier and less
> complicated.

In this case I believe using "de" is probably not even
necessary[*] and using "di" is sufficient.  The problem here has
to do more with not knowing when the footnotes will be output,
and keeping the footnotes separate is an easier solution than
collecting them all in a single diversion and then having to
split up that diversion again.  Thus, as long as the footnotes
themselves make no reference to the page number on which they
are output, they can be formatted immediately when encountered.

[*] Plus, if you're using equations, you'll have to change the
escape character while defining the footnote macro, to prevent
eqn-escapes from being expanded while the footnote is read.

Below is a simple solution in which the footnotes are formatted
into (separate) diversions, and references are placed into
the main diversion "a", which then append the footnote calls
to the main footnote macro "fnote". (In the solution below,
"fnote" is not a diversion which contains the footnotes, but
rather only a macro which itself calls the individual footnote
diversions.)  (Note also that since the footnotes are formatted
when they are originally read, the page number in the example
footnote is of course also fixed when the footnote is read,
not when it is output.)


.\" eqn tbl
.\" ----------------------------------------------------------------
.EQ
delim $$
.EN
.\" ----------------------------------------------------------------
.de fn((
\s-2\u\\$1\d\s0
\!.fnref \\$1
.ev note
.ft R
.ps 8
.vs 10p
.ll 20P
.di fn\\$1
\\$1.
..
.de fn))
.br
.di
.ev
..
.de fnref
.ie !'\\n[.z]'' \!fnref \\$1
.el \{.am fnote
.fn\\$1
.rm fn\\$1
\\.. \}
..
.\" ----------------------------------------------------------------
.sp 1i
.po 1i
.ps 11
.vs 13p
.ll 20P
.\" ----------------------------------------------------------------
.di a
Even without publication, Nightingale's \fISuggestions for
Thought\fP attracted much scholarly attention. Several editions
of excerpts have been published. Three books of excerpts, and a
separate edition of ``Cassandra,'' were published later in the
twentieth century.\c
.fn(( 1
Michael D. Calabria and Janet A. Macrae, eds.,
\fISuggestions for Thought by Florence Nightingale\fP.
.TS
allbox tab(;);
n c.
\-0;$ exp ( x ) = sum from {i=0} to inf {x sup i} over {i !} $
3.1415;Hello, world!
.TE
.sp .5
.fn))
As usual the official biography, E. T. Cook's \fIThe Life of
Florence Nightingale\fP, can be counted on for excellent
background on the purpose and writing.\c
.fn(( 2
Another footnote on page \n%.
.fn))
.br
.di
.nf
.a
.sp
.fnote
.rm fnote
.\" ----------------------------------------------------------------






reply via email to

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