groff
[Top][All Lists]
Advanced

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

Re: [Groff] pointsize changes in .NH ms-macro


From: Keith MARSHALL
Subject: Re: [Groff] pointsize changes in .NH ms-macro
Date: Fri, 10 Sep 2004 10:41:44 +0100

Joerg van den Hoff wrote:
> Keith MARSHALL wrote:
>> Or, slightly simpler, since the bottom of page trap will reset the
>> line height to \n(VSp anyway, when it is sprung ...
>> 
>>     .de SHEAD
>>     .\"inputs: $1: NH-level, $2: title
>>     .\"------
>>     .br
>>     .nr incps 4-\\$1
>>     .if \\n[incps]<0 .nr incps 0  \"just in case ...
>>     .vs +\\n[incps]p
>>     .ne 3v+\\n[\\n[.ev]:PD]u+\\n(.Vu
>>     .nr PS +\\n[incps]
>>     .nr VS +\\n[incps]
>>     .NH \\$1
>>     \\$2
>>     .nr PS -\\n[incps]
>>     .nr VS -\\n[incps]
>>     ..
>> 
>> Best regards,
>> Keith.
>> 
> Keith,
> thank you very much for your help. my problems are solved in this 
respect.

I am pleased to have been able to help.  You aroused my interest, because
I was thinking of adding similar functionality to an ms extension package
of my own -- to add support for various PDF document features -- so we
both benefit :-)

> as a follow up question (to everyone):
> 
> is there a straightforward way to get the current section title _and_ 
> section number into the page header under all conditions?
> I have attached an example, showing what I have managed to get: always 
> the correct (current) section title. what I do _not_ get is the correct 
> section number if the new section starts at the top of a new page (in 
> the example this happens on page 3).

This is not as easy, but should be achievable.

With the current implementation, we rely on .NH to set the section number,
but to get the *next* section number in to the *preceding* header -- the
page trap which writes the header is sprung just before the call to .NH
-- we need to pre-empt the adjustment which .NH will make to \*(SN.  We
could achieve this in SHEAD, by adding some additional logic in place of
the .ne request, but perhaps the simplest, and cleanest, mechanism would
be to provide our own redefined implementation SH-NO-TAG, which is the ms
internal macro used by .NH and .SH, to force a page break when required
-- it is invoked *after* the new section number has been set.

I may find time to play with this a bit more, over the weekend.

> if someone cares to have a look, the logic is as follows:
> 
> the macro SHEAD sets a string register \*(xx which is inserted by a 
> modified PT macro in the  page header (along with a horizontal line). 
> (page 1 is intentionally treated different, i.e. no page header is 
> created). moreover the value of \n[SN] is inserted in the page header. 
> in additon, table of content entries  are collected.
> 
> this works fine if the current section extents across the page break. if 

> not so (i.e. if new header starts  at top of page) the SN register has 
> still it's old value (i.e. it seems updated only after the bottom of 
> page trap is triggered by .SH). in the example, page 2 and 4 are ok, 
> page 3 is not.
> 
> 
> regards,
> 
> joerg
> 
> 
> PS: of course it would be even nicer not to get title and number of the 
> _current_ section into the page header but rather the section number and 

> title of that section  which starts _anywhere_ further down on the page 
> (as in every decent book). in the example, page 4 should in this case 
> have a different page header. is this possible to achieve with a 
> one-pass-formatter?

This isn't possible in one pass.  However, you can probably achieve the
desired effect in two passes, with a bit of sed, awk or perl scripting
between -- hint: use .tm to write section head info to stderr, during
pass 1, invoking groff as (say) ...

    groff -ms -Z -rPASS=1 source.ms 2>&1 1>/dev/null > out.tmp

filter out.tmp with sed, awk or perl, to create a new file containing
.ds records to define the required page header elements, and source this
in pass 2, e.g. ...

    groff -ms headers.ds source.ms > output

HTH.

Best regards,
Keith.




reply via email to

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