[Top][All Lists]

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

Re: [Groff] Resolving Forward References

From: Andrew J. Piziali
Subject: Re: [Groff] Resolving Forward References
Date: Fri, 2 Jan 2004 16:36:04 -0600 (CST)

Ted, you wrote:

    On 02-Jan-04 Andrew J. Piziali wrote:

    >    As I understand it, groff is a single-pass formatter.  As such,
    > what is the recommended way to resolve a forward string or
    > register reference?  For example, using the ms macros, I have a
    > footnote:

    >     .FS
    >     The process of using code coverage is discussed in section
    >     \*[useModelSectionNumber], \(lqUse Model.\(rq
    >     .FE

    > which references a document section number later in the document.
    > The section number is stored in the string register
    > useModelSectionNumber, after it is computed by the .NH section
    > header macro.
    Single-pass indeed -- but nothing stops you using it twice in a row
    under different conditions ...
    One way round this problem is to set a "flag" at the beginning of
    the file, say
        .nr run1 1
    and then, at appropriate places, put in a call to a macro which
    tests \n[run1] and, if >0, writes out to a file (say xrefs.troff) a
    line like
        .ds useModelSectionNumber \\*[SN]
    where \*[SN] (or \n[SN], depending) is the section number which,
    by then, will have been constructed.
    At the end of the run, you then have a file full of such definitions
    which you can read in on the second pass.
    More precisely, you can start your file with
        .nr run1 1
        .if !\n[run1] .so xrefs.troff
    and then, for the second pass, change the first line to
        .nr run1 0

I hadn't even considered manually running both passes and using a
temporary file.  Should I just dispose of the formatter output on the
first pass?  In other words, I would use the command pair:

        groff -rFirstPass=1 -e -p -t -ms -Tps >/dev/null
        groff -rFirstPass=0 -e -p -t -ms -Tps >


address@hidden                       ________------+------________
                                                       / \

reply via email to

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