[Top][All Lists]

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

[bug #62825] Incorrect section number using \*($n in a header

From: anonymous
Subject: [bug #62825] Incorrect section number using \*($n in a header
Date: Wed, 27 Jul 2022 21:01:57 -0400 (EDT)

Follow-up Comment #3, bug #62825 (project groff):

This seems to be about how and when groff prints the headers on each page.
Notice that the only thing that's correct on each page of the output is the
page number. After page 1 the chapter number in the header is then correct as
well. However, at the start of page 2 when it's time to print the header, it
seems groff doesn't know yet that the section number has changed. My guess is
that maybe groff prints to a page from the top down without ever going back up
to possibly reformat the header.

For example, suppose you put the same information in the footer:

.de $f
.tl 'Chapter \\n(ch'Section \\*($n'Page \\n%'
.sh 2 "Section 1.1"
This is the first section.
.sh 2 "Section 1.2"
This is the second section.
.sh 2 "Section 1.3"
This is the third section.

Then all the information in the footer is correct, even on the first page:

$ nroff -ww -me section_test2.roff | cat -s
troff: section_test.roff:5: warning: macro '$C' not defined
troff: section_test.roff:6: warning: number register '$1' not defined

                         CHAPTER  1

1.1.  Section 1.1

This is the first section.


Chapter 1                Section 1.1                  Page 1

1.2.  Section 1.2

This is the second section.


Chapter 1                Section 1.2                  Page 2

1.3.  Section 1.3

This is the third section.


Chapter 1                Section 1.3                  Page 3

So it seems that groff does a single pass through each page from top to
bottom: start a new page, then print the header, then print the body, then
print any footnotes, then lastly print the footer. It then starts the next

It makes sense that the footers would be correct, because by that time groff
would know the current chapter and section, from the $c and .sh commands that
were already executed in the body, *after* the header was created when the
page began.

So is that how groff works? Or does groff ever "go back", upward to return to
the header for additional formatting?


Reply to this item at:


Message sent via Savannah

reply via email to

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