linuxunixgrofftroff

Setting top margin in groff to zero using mm macros


I am trying to define the top (and bottom) margins in groff to 0cm.

For the page offset is easy to define whatever margin you want, but I am not being able to achieve the same for the top and bottom margins.

This is what I have tried:

.PH ""
\" ***************
\" 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 0        \" 1v+footer+even/odd footer+2v
.nr pg*header-size 0        \" 3v+header+even/odd header+2v
.nr pg*extra-footer-size 0
.nr pg*extra-header-size 0
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.
.SK
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.

After generating the ps file:

groff -Tps -P-pa4 -mmm sample3.mm > sample3.ps

this is the result, clearly the top margin is not 1.5cm as in the left margin:

Margins


Solution

  • mm uses the .TP macro to process the top of each page. This includes the vertical spacing at the top. Redefining this macro will stop any header space being reserved.

    .pl 29.7c           \" PAGE LENGTH
    .po 1.5c            \" PAGE OFFSET
    .ll 18.0c           \" LINE LENGTH 
    .de TP
    ..
    Lorem ipsum etc.
    .SK
    Lorem ipsum etc.
    

    For reference, the old mm manual states:

    9.8 Top and· Bottom (Vertical) Margins

    .VM [top] [bottom]

    The .VM (vertical margin) macro allows the user to specify additional space at the top and bottom of the page. This space precedes the page header and follows the page footer. The .VM macro takes two un scaled arguments that are treated as v's. For example:

    .VM 10 15

    adds 10 blank lines to the default top of page margin and 15 blank lines to the default bottom of page margin. Both arguments must be positive (default spacing at the top of the page may be decreased by redefining .TP).

    (my italicization)