[Top][All Lists]

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

Re: How to use refer macros-agnostic way?

From: Ralph Corderoy
Subject: Re: How to use refer macros-agnostic way?
Date: Fri, 03 Jan 2020 16:43:06 +0000

Hi Piotr,

> my impression is that groff cannot print references or a bibliography
> list, if not compiled together with some macro set: -ms, -mm, etc.

refer(1) is a preprocessor that outputs assignments to registers and
macro invocations.  It is up to something downstream to provide macro
definitions that produce the user's desired document content.  That
something else may be -ms, as you suggest.

> Since I am used to working with GROFF without any standard macro sets
> and use my own super-compact macro set serving all my needs, I wish it
> was a way to print, say, a bibliography list via
> .[
> $LIST$
> .]
> without invoking any standard macros as they may mess with my own ones.

That's fine.  Your super-compact macro set needs to implement the macros
refer calls.

Taking your two example files,

> 2. groff -eR            test.roff >
> 3. groff -eR -mrefer    test.roff >

These two give the same output; nothing appears for $LIST$.

> 4. groff -eR -mrefer-ms test.roff >

The $LIST$ content appears, but just as a paragraph of text.

> 1. groff -eR -ms        test.roff >

This produces good content for $LIST$; indented, etc.

> et-al " et al." 2 3

You may want " et al.\&" so the full stop doesn't trigger
end-of-sentence spacing.

> Here is a reference to 
> .[
> Estimation
> .]
> and another to 
> .[[
> Large Imagery
> .]],
> for another example.
> .[
> $LIST$
> .]

You should run refer directly on your example file and example how it's
changed it.  For example,

    $ refer test.roff | grep -v '^\.lf' | diff test.roff -
    < Here is a reference to 
    < .[
    < Estimation
    < .]
    < and another to 
    < .[[
    < Large Imagery
    < .]],
    > Here is a reference to  [Blais 1988]
    > and another to [Tan et al. 1999],

shows the references.  The two spaces before `[Blais' is because you
have an unwanted trailing space after `reference to'.

$LIST$ becomes a long set of lines, starting

    > .]<
    > .\"blaisj a r1988
    > .ds [F Blais 1988
    > .]-
    > .ds [A J.A.R. Blais
    > .ds [C University of Calgary
    > .ds [D 1988
    > .ds [I University of Calgary Press
    > .ds [T Estimation and Spectral Analysis
    > .ds [W my copy at school
    > .nr [T 0
    > .nr [A 0
    > .][ 2 book

It's calling macros `.]<', `.]-', and `.]['.  If no definitions of those
exist then no output is produced.

You'll find it useful to examine
/usr/share/groff/1.22.4/tmac/refer.tmac, adjusting to suit your local
installation.  It provides a `.]<' definition, for example, that calls
ref*biblio-start-hook if it exists.  There's a lot of instructive
comments at the start.  Thus you can either implement `.]<' directly,
and I assume that's your preference, or have a higher-level interface by
involving -mrefer.

Then look at refer-ms.tmac.  It uses refer.tmac's interface, providing
definitions that call -ms macros.

Cheers, Ralph.

reply via email to

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