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 .hl .tl 'Chapter \\n(ch'Section \\*($n'Page \\n%' .. .$c .sh 2 "Section 1.1" .lp This is the first section. .bp .sh 2 "Section 1.2" .lp This is the second section. .bp .sh 2 "Section 1.3" .lp 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 page. 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: <https://savannah.gnu.org/bugs/?62825> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/