linuxunixgrofftroff

Defining the header in groff mm does not change it in the first page


I am trying to define a custom header in groff using mm macros.

If I define .PH it takes effect on page 2, but not on page 1.

Why is this happening?

% cat sample2.mm 
\" ***************
\" PAGE DEFINITION
\" ***************
.pl 29.7c           \" PAGE LENGTH
.po 1.5c            \" PAGE OFFSET
.ll 18.0c           \" LINE LENGTH 
.nr pg*top-margin 0     \" MARGIN VARIABLES
.nr pg*foot-margin 0
.nr pg*block-size 0
.nr pg*footer-size 5        \" 1v+footer+even/odd footer+2v
.nr pg*header-size 7        \" 3v+header+even/odd header+2v
.nr pg*extra-footer-size 0
.nr pg*extra-header-size 0
\" ****************
\" HEADER
\" ****************
.PH "'LEFT'CENTER'RIGHT'"
\" ****************
\" FOOTER
\" ****************
.BS             \" CUSTOM FOOTER
CUSTOM FOOTER BLOCK
.BE
\" **************
\" BEGIN DOCUMENT
\" **************
.P
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

.AV "Approver" "Company" [ ]
.SK
.P
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

This is what I get.

For page 1, the header is the default one: page1

For page 2, the header is the expected one: Page2


Solution

  • .PH defines the page header for the next page and further. If anything has been done on the first page, including seeing some comments, the headers in .PH arguments are used from the second page.

    If you move the .PH line to the top, it will be processed for the first page too. Don't put any comments above it.