groff
[Top][All Lists]
Advanced

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

Re: [Groff] tbl footnotes and graph position


From: James K. Lowden
Subject: Re: [Groff] tbl footnotes and graph position
Date: Thu, 1 Dec 2011 22:36:54 -0500

On Thu, 1 Dec 2011 16:19:17 +0100
Tadziu Hoffmann <address@hidden> wrote:

> Where are the actual footnotes?

I hadn't noticed!  :-/  I was so excited about the row height that I
stopped looking at the bottom of the page.  

> You can transparently embed the footnote requests in the
> table-cell diversion, so that they are only executed when
> the diversion is replayed, not when it is created.  To do
> this, add "\!" to the beginning of the lines containing
> the footnotes:
> 
>   T{
>   Annualized Return\*[*]
>   \!.FS
>   \!Compounded Annualized Return 
>   \!.FE
>   T}  abc

http://www.schemamania.org/tbl/eg/

Wunderbar!  That does it exactly.  Thank you.  

Let me see if I understand what's going on here.  (Ossanna and
Kernighan give us only one paragraph on \!.  A little unpacking
may be necessary for us mortals!) 

1.   TS, tbl starts
2.   tbl sees T{ ... T} and invokes troff
3.   troff produces the footednoted text, and 
4.   *copies in* the footnote macro, but does not execute it
    The troff output is:
        [a troff ditroff (?) block]
        .FS
        footnote
        .FE
5.   tbl renders the troff output in the cell
6.   TE, tbl ends
7.   troff runs with -ms
8.   troff encounters the footnote text in FS ... FE 
9.   troff writes the footnotes to a diversion
10. troff reached end-of-page, traps, emits diversion

Because FS ... FE are guarded by \!, troff merely passes them back to
tbl (with \! stripped off).  troff computes the size of its output
block without the guarded lines.  tbl accepts the troff output and
metrics verbatim, and blindly copies the troff output -- containing the
now unguarded but still unprocessed FS/FE pair -- to its output.  When
tbl has completed pre-processing the file, the output is piped to
troff, which processes the FS/FE pair as ususal.  

Observation: the need to guard FS/FE from the inner troff processing is
imposed by the document format, by the requirement that FS/FE appear
immediately after the footnoted text.  The escaping would not be
necessary if the footnotes could live outside the table.  

And, in fact, that works, too.  My file t.footnotes-outside-table.ms
renders exactly as t.footnotes-inside-table.ms.  The only caveat being
that by delaying the appearance of FS/FE in the overall document, one
runs the risk of the page ending before FS/FE is encountered, a
situation unlikely to end well.  

There's no way to change FS/FE to deal with this situation, because
there's no way for it to know that it's being called from within tbl
and shouldn't render the diversion yet.  

We could modify tbl to look for footnotes and transparently
escape them.  Does that sound the like the right answer to you?  

This has been a very interesting diversion for me, if you'll pardon the
pun.  I hope others feel the same.  

Regards, 

--jkl



reply via email to

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