groff
[Top][All Lists]
Advanced

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

RE: [Groff] delayed


From: Ted Harding
Subject: RE: [Groff] delayed
Date: Wed, 09 Jul 2003 00:51:56 +0100 (BST)

On 08-Jul-03 Mohammad Razwan wrote:
> I was just wondering, about delaying 
> the outputting of the header on the 
> current page.
> 
> What I want to do is to output:
> .tl 'Section \\n[SecNo]'\\*[SecName]'\\n[%]'
> 
> where the the register SecNo and string SecName reflect the situation
> on the 
> current page, that is, if a section 
> begins on the current page then that 
> section number and name should reflected 
> at the top.
> 
> Currently, I am not able to reflect the 
> fact that a new section has begun on the current page, the header still
> shows the values held from the previous page (except the page number
> which is correct).
> 
> Any help/suggestions/tips would be appreciated.

As you realise, you cannot do this until groff has found out what is on
the page, and normally the header is macro'd to be output when the new
page is begun (by which time, of course, it knows what the new page number
will be).

The simplest (but by no means really simple) way to do this is to delay
printing the header until the bottom-of-page macro (all the stuff that
happens when the end-of-page is reached, but before the next page is
started). In ms macros, this takes place in the macro ".BT". You will
have to find what corresponds to this in the macro package you are using.

Having found it, you then have to re-write it (you can simply place the
new version at the beginning of the document; it will overwrite what the
original macro paclage said). The tricky part is to print the header in
the right place, which involves a motion back up to the top of the page
into the header margin. You can use

   \v'|Vplace'u\h'|Hplace'u

for this, where you may have to experiment a bit with Vplace and Hplace,
and you can replace "u" (machine units here) with whatever distance units
you find convenient. After that, you can output your ".tl".

Also, of course, you will have to watch the logic of the section number,
since presumably you want this to be the first which occurs, in case there
are two or more. So part of your new macro will have to set a flag to zero
for each new page until a new section is encountered, whereupon you record
the new section number (for delayed printing) and set the flag to 1 (so
that you don't do it more than once). But if there are two or more new
sections on a page, then the section number for the next page will have to
be the _last_ section on the current page (unless there's a new section
on the next page); so you have to keep track of that as well! Unless, of
course, you want to print a header which announces both the first and the
last sections (this can happen in dictionaries, for instance, where
"section" means "entry"). So this part is also tricky ...

Good luck!
Ted.


reply via email to

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