[Top][All Lists]

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

[Groff] Copying blocks of troff input to a file

From: Ted Harding
Subject: [Groff] Copying blocks of troff input to a file
Date: Wed, 24 Dec 2003 10:23:30 -0000 (GMT)

Greetings all, and a happy festive season and new year to all!

A question. I'm trying to devise a pair of macros (say .TO and .TQ)
such that

one or more lines of troff input


a) append these input lines verbatim to another file
b) leave them stilll available as troff input

The objective is to set up a separate file which is already suitable
for groff to generate a Table of Contents for the document in the
original input (which will in fact be split between several input

In the case where each TOC item is one line of inout only, the following
macro will do the job (with groff in "unsafe" mode, of course):

.de TO
.opena TOCout
.write TOCout .XA \\n[PN]
.write TOCout \\$*
.write TOCout .XE
.close TOCout

(.XA and .XE are the TOC macros from s.tmac)

Then, for each one-line item which is also to appear in the TOC,
you can write

.TO Line_for_TOC

and then in the file you will find

.XA the_page_number_where_called
.XA the_page_number_where_called_next

and also these input lines in the original file will have been
processed by groff (because of \\$*) and will be formatted in the
output as though .TO had not been there in the first place.
The original input line Line_for_TOC will appear exactly copied
in the auxiliary file, so when is processed its
contents can be formatted identically to the main document.

So far so good. However, this only works for single input lines.
What I really want is a macro pair such that


will append the following to

.XA the_page_number_where_called
verbatim copy of Block_of_input_lines

and at the same time leave the block of input lines available
for processing by groff as if .TO/.../.TQ had not been there.

The last bit could be done by reading back from a diversion,
but I'm not seeing how to combine this with the first bit
(indeed I'm not seeing how to do the first bit anyway!)

The underlying objective is to completely separate the formatting
of TOC from the formatting of the document itself, and also allow
appending of TOCs for different chapters (in different source files)
to a single file, which will then be available for any
subsequent editing and separate processing.

One application is captions for tables and figures, as well as the
usual chapter titles and section headers (which may extend over more
than one line).

Thanks for any suggestions!

Best wishes to all,

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 24-Dec-03                                       Time: 10:23:30
------------------------------ XFMail ------------------------------

reply via email to

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