How do I show section and chapter in header and footer [Solved]

I have documents with major sections each of which has a number of chapters. I would like to put the section name in the header and the chapter name in the footer.

My first thought was to make the sections a heading 1 style and the chapters a heading 2 style. But I can’t put heading 2 into the footer

Making a new style for each section is not a viable option

Here is a test document.
test-headings.odt

As you can see in page 4 the footer is ‘Section 2’ where it should be ‘Chapter 3’.

First, let’s clear a vocabulary problem. I assume that your “sections” are the main first-level subdivisions of your document and contain then “chapters” as a second-level hierarchy. With this ordering, section heading are “naturally” styled Heading 1 and chapters Heading 2.

The styles are applied to the relevant paragraphs in the text flow.

In the header, you Insert>Fields>Other, tab Document, choosing Type Chapter, Format either Chapter name or another one if you want the number also displayed. Check that Level is 1 to reference the current Heading 1 title.

In the footer, you insert a similar field, but you set Level to 2 to reference the current Heading 2.

But, the captured Heading x is the one active at time of the capture. Said otherwise, you have no problem in the header because the first Heading 1 in the page is used. However, in the footer, you display the last Heading 2 of the page, which may confuse the reader if you have a change in the middle of the page.

Note: when you write

But I can’t put heading 2 into the footer

I hope you did not style the text in the footer as Heading 2 . This will never work.

EDIT 2018-03-23

You define your new “sections” with a Heading 1 paragraph. You enabled the Hidden attribute in the style to make it invisible.

As far as I know, the Hidden attribute is meant to remove completely the flagged paragraphs as if they were never inserted. This allows to print several versions of the same document simply by adjusting the attribute. In academics, thinks for instance of the teacher and student books.

Here you attempt a border line usage. I am surprised that it half works, but that may be a side effect of Heading x special properties.

Heading 1: despite being hidden, the heading is entered into the known list of headings but all other effects are disabled as expected (for instance, I added a page break to force your “section” on a new page but it did not work because paragraph is hidden).

Heading 2: bears the page break to right page to force your “chapters” to begin on a new page and, also, enters the heading in the known list.

However, with this scheme, I see two pitfalls.

  • Since your Heading 1 is hidden, your section does not start systematically on a new page. This is what happens in the last page of your “section” 1. The Heading 1 for “section” 2 is part of this page, so that when we reach the footer, this Heading 1 is now the current one. We’re already in “section” 2 while you intend it be effective only after the Heading 2 for the new “chapter”. Keep with next paragraph could have solved the issue, but it has no effect since the paragraph is hidden and, nevertheless, it is overridden by the page break in Heading 2.

    I experimented with a page break to fix the issue but since Heading 1 is hidden, it does nothing.

  • If you start your new “section” with an introductory text not preceded by a Heading 2, this introduction appears sequentially in the same page as the last paragraphs of the previous “section”. Moreover, in this configuration, the reference to the latest level-2 heading seems to pick up the latest in the previous “section” instead of being reset.

Suggested fix

“Sections” in a book are significant. Instead of hiding “section” change, make them explicit wit a visible (= not Hidden) Heading 1 paragraph. Since it is an important break in the book, use a page break in the style definition and adjust “before” vertical spacing so that it is approximately centered in the page. You may also center the heading between its margins. Your Heading 2 already forces a page break, so you don’t need to bother with “below” vertical spacing, unless you care for an introductory text.

To avoid unelegant look, use a simple page style without header nor footer (or limited to page number) so that the “section” title is not repeated. You can eventually set a Next page style in the Organizer tab so that you automatically switch to your common page style, should you add text after the “section” heading.

There remains a small glitch. If your introductory text (not preceded by a Heading 2) spills over to next page, the level-2 heading reference does not exist and the field will revert to level-1 instead of being blank.

Please give feedback in comments.

If this answer helped you, please accept it by clicking the check mark :heavy_check_mark: to the left and, karma permitting, upvote it. If this resolves your problem, close the question, that will help other people with the same question.

1 Like

I meant to say that I tried to put the chapter name level 2 into the footer.

Your explanation of the flow makes a lot of sense. To expand on it a little: a new heading 1 (level 1) will wipe out all the levels 2,3,… Until there is a heading 2, chapter level 2 will show the level 1 or heading 1.

Thanks

The problem comes with my last sentence.

What I tried was to make heading 1 non-print and heading 2 force a new right page. The problem is that on the last page of my section 1 the footer shows the heading 1 name for section 2 instead of the heading 2 name of the old heading 2 because a new heading 1 wipes out the heading 2.

I still think that there needs to be a way to change the header and footer without having to go through the kludge of new styles.

This should not be a problem. Attach your file in the original question and I’ll have a look at it. I think it’s only a matter of placing the page break to the right place.

You should use Heading 1 for sections and Heading 2 for chapters, but make sure you know where to put page brakes. Think this might help.

Is this what you’re looking for: fixed-sectioning.odt?

Write your document with Heading 1 representing sections and do not hide them till the very end, hide them just before printing. Check if that works.

I came up with a different solution because the chapters should force a right page unless they immediately follow a section heading.

So:
Heading 1 forces a break to a right page and is centered with a next style of Heading 2a
Heading 2 forces a break to a right page
Heading 2a is the same as Heading 2 and is level 2 but doesn’t force a new page

Thanks for your help

Then be kind enough to the community by closing your question.