[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Question re: Appending to a diversion
From: |
Werner LEMBERG |
Subject: |
Re: [Groff] Question re: Appending to a diversion |
Date: |
Sun, 18 Dec 2005 12:52:33 +0100 (CET) |
> I am attempting to create a set of footnote macros for a book
> I am typesetting for a friend. I am including a segment from the
> macro code to show how I am trying to create the diversion on each
> page. [...]
Appended is something which works. There were a few problems:
. If-else clauses look like this:
.ie ... \{\
...
.\}
.el \{\
.\}
Note the trailing backslashes! I think this was the reason of
not getting more than a single footnote.
. Hard-coded environments are bad. You should used named ones like
.ev env-footnote
. Hard-coded font positions are bad. Use named fonts like
\f[B] ... \f[]
. It's not necessary to double backslashes for escape sequences
which don't expand.
\u, \f, \d, \|, \c
. Arguments at the end of a line should be protected with an
immediately following comment escape to avoid trailing whitespace.
. ft B
\\$1\"
. ft
. Incrementing a number register has simpler syntax:
.nr foo +1
. I've used the `.nop' request to have proper indentation -- this is
a matter of taste.
Note that the solution you are trying is not optimal. You have to
pass the whole footnote as an argument to the `.footnote' macro. A
much better solution is to provide two macros, `footnote-start' and
`footnote-end', to open and close the footnote diversion:
.footnote-start
footnote text
footnote text
...
.footnote-end
Hope this helps.
Werner
======================================================================
.de footnote
. ev 4 \" Set up using environment 4
. ps 9 \" Point size
. vs 10 \" Line spacing
. ll 4i \" Specify line length
. in .1i \" Footnote paragraph indent
. \" If footnote flag is set, not first note:
. ie \\n[footnote_flag] \{\
. da foot_text \" Append footnote number & text arg
. sp .5v \" Space between footnotes
. ti -.1i \" Unindent for footnote number
. nop \u\f3\\$1\fP\d\|\c
. \" Process footnote text string
. nop \\$2\"
. br \" Break collected line
. da
. \} \" End diversion append
. \" If footnote flag is not set, first note:
. el \{\
. di foot_text \" Start new diversion
. ti -.1i \" Unindent for footnote number
. nop \u\f3\\$1\fP\d\|\c
. \" Process appended footnote text string
. nop \\$2\"
. br \" Break collected line
. di
. \} \" End diversion
.
. ev \" Return to previous environment 0
.
. nr footnote_flag +1
..
.
Text before the footnote.
.
.footnote 1 "\
This is a first try of a footnote. \
This is a first try of a footnote. \
This is a first try of a footnote. \
This is a first try of a footnote. \
This is a first try of a footnote."
.footnote 2 "\
This is a second try of a footnote. \
This is a second try of a footnote. \
This is a second try of a footnote. \
This is a second try of a footnote. \
This is a second try of a footnote."
.
Text after the footnote.
.
.sp 2
.
.nf
.foot_text
.fi
.
.\" eof