Ask Your Question

Dynamic headers

asked 2021-04-16 10:27:38 +0200

MSPhobe gravatar image

updated 2021-04-28 20:01:04 +0200

Alex Kemp gravatar image

Suppose I was writing a 30 page book, with 3 chapters...

Chapter One Chapter Two Chapter Three

... and I want "Chapter X" to appear in the header on each page, with "X" changing as you proceed through the book.

Now... this CAN be done, up to a point, with page styles, I know. But....

Let's further say that originally, Chapter 1 was pages 1-9, C.2 10-19, C.3 pgs 20-30

And that I don't want a page break at the end of each chapter, but I DO want flexibility.

Let's say I revise the book, add 3 pages to Chapter 1. Now pgs 10-12 will be part of Ch.1. (And other chapter boundaries will change as well, of course.)

Under any "make the headers different on different pages" scheme that I am familiar with, pgs 10-12 would still have "Chapter Two" in their headers, I think. Yes?

Is there a way to put some kind of hidden "marker" in the text at the points where chapters end, and have the headers reflect where those markers fall in the document?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2021-04-16 10:41:39 +0200

You don't need page breaks or different page styles. In the header, the chapter taken as reference to populate the field in the header is the one of the first paragraph.

If you put the field in the footer, the chapter of the last paragraph of the page will be taken as reference.

So basically, you don't need to hardcode the chapter number with different page styles, use the menu Insert > Field > More fields and in the Document tab, select the Chapter type and add the format(s) you want to insert. It will be updated dynamically in the header.

To show the community your question has been answered, please tag the best answer (), and/or vote for any helpful answer. Else, please edit your question to add information (answers are for solutions only).

edit flag offensive delete link more


In short, make sure that the heading that announces a new chapter (typically heading 1) is always the first paragraph of a page. Make sure that you turn on heading numbering in Tools - Chapter Numbering, then the correct number will be used in the chapter number field in the heading as described by Hagar Delest.

floris v gravatar imagefloris v ( 2021-04-16 11:28:48 +0200 )edit

Brilliant answers! Thank you. I will mark "answered" as soon as I've had a chance to "play" with the ideas, confirm that they work as I expect they will. (I.e. that I am understanding the answers given!)

MSPhobe gravatar imageMSPhobe ( 2021-04-16 13:15:47 +0200 )edit

answered 2021-04-16 11:29:59 +0200

ajlittoz gravatar image

To automate the process, you must use styles.

The first category is paragraph styles. Among those, the Heading n (n=1 to 10) is intended to define the outline of your book: level 1 = chapter, level 2 = sub-chapter, etc. All you need to do is to assign the required style to the paragraph making the heading.

What this does is flagging the paragraphs so that Writer identifies them as members of the outline. A side-effect is the possibility to build automatically a table of contents and also to (cross-)reference the headings and their properties from elsewhere in the text.

Customizing Heading 1, you can alos add an automatic page break before the paragraph in setting the option in the Text Flow tab of the style definition, so that your chapters always start on a new page. With advanced configuration, you can also constrain this page to always be a right page (odd-numbered).

The use of the Heading n family results in the definition of various fields. To get the chapter name in your header, Insert>Field>More Fields. In the Document tab, you find Type Chapter giving access to the outline properties. The Format list allows you to insert Chapter name, Chapter number or both. Level is the means to reference chapter (level 1), sub-chapter (level 2), etc.

The field insertion will impact all pages using the page style.

If you need pages with other information than chapter name, e.g. a specific header for TOC or no header at all for cover and back page, you must use other page styles for these pages.

I recommend you read the Writer Guide for an introduction about what can be done with styles and fields.

To show the community your question has been answered, click the ✓ next to the correct answer, and "upvote" by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.

edit flag offensive delete link more


What is the point duplicating the information already provided 30 minutes ago?

You could have added the additional information in a comment. In fact you just want to get more karma by getting the correct answer tag, knowing that your answer has much more information.

This is quite laughable. I also saw that you even warn users when they just got enough karma to upvote one of your replies.

To clarify: I could also post a long and detailed post about all the intricacies of the feature. However, I believe in progressive disclosure vs. lesson teaching (your strategy). Meaning that first, too much information is boring and can prevent the key information to be quickly understood and second, better have the user discover himself how it works with an interactive discussion. If they come to a collaborative platform, it's not to be served a help file section.

Hagar Delest gravatar imageHagar Delest ( 2021-04-16 12:06:35 +0200 )edit

Stop bashing! This is cross posting problem. I am rather slow writing because I simultaneously check menu item wording, dialog layout, sometimes also experimenting, and so on. As a consequence, my answers are not instantaneous. I saw your answer once I hit Save. So what should I do? Delete my answer because someone else gave one. Take the example of StackExchange where numerous redundant answers are given. Community then sort things out.

Using this site is a nightmare for newcomers. The usage rules are deeply buried. The privileges associated with karma are obscure. @manj_k and @LeroyG did a good job to clarify that but this needs to be reminded over and over.

Your complaint about karma is ridiculous. I won't get any additional privileges. However, upvoting answers is a good discipline so that when questions are queried on the site, they are returned in order of relevance. Yes, upvoting ...(more)

ajlittoz gravatar imageajlittoz ( 2021-04-16 13:14:58 +0200 )edit

So what should I do? Delete my answer because someone else gave one.

Yes, that's what I do personally. Quite frustrating but that's part of the game.

Hagar Delest gravatar imageHagar Delest ( 2021-04-16 14:05:28 +0200 )edit

Actually, I found the "extra" statement of "the solution" HELPFUL. I often find hearing things two ways helpful. I will, in fact, be adding a third, as neither of the answers posted made complete sense TO ME. They "didn't work", as I read them. (They HAVE put me on the road, though... thank you BOTH for your efforts.)

MSPhobe gravatar imageMSPhobe ( 2021-04-17 11:16:27 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2021-04-16 10:27:38 +0200

Seen: 53 times

Last updated: Apr 16