Change page style without adding page break

I am creating a document similar to a dictionary. I want to place in the page header the current word whose definition is below in the text of that page but without adding a page break because the definition text must flow seamlessly from one page to another without a break. For example, see below how the page that ends with the word “brown” must flow seamlessly to the next page without a page break in between, but in the page header of page 2 I need a new page style that has the word “Chocolate Cake” in the header. The only way I know to have a new page style on page two is to insert a page break after the word “brown,” but that will prevent the text from flowing seamlessly from page 1 to page 2.

Chocolate Cake


A chocolate cake is a


delicious yummy brown


(bottom of page 1)

(page header) Chocolate Cake


thing that you will love


to eat because it’s made


of chocolate…

What you want in fact is not to change page style but to change header contents. Although this is obviously linked because a page style can have only one header, you can achieve your goal with “dynamic” headers.

What you need is a field in the header capturing information from the first paragraph of the page.

This is usually done styling some paragraphs with Heading n styles, structuring the document as chapters, sub-chapters, etc. Since your document is akin to a dictionary, it is not supposed to be broken into chapters. Provided you customise the Heading n styles, you can use them to mark the occurrence of a term with Heading 1, some “technical” information with Heading 2 and let the definition be in regular Text Body.

With such an organisation, you can then Insert>Field>More Fields, Document tab, Chapter type, Chapter name format, level 1.

When a new page is allocated, this causes the “context” of the first paragraph to be examined. The current Heading 1 is retrieved and its properties are used to generate the header.

This means the first page may not be “titled” if the first paragraph is not a Heading 1. Subsequent pages will all have a “title” if some Heading 1 occurred before switching to a new page. If the first paragraph in a page is a Heading 1, its content will be used in the header instead of the one current at end of the previous page.

You’ll need to experiment a bit to decide what exactly should be put in Heading 1 paragraphs. Of course, Heading 1 must not force a page break in its Text Flow tab.

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!

EDIT 2019-12-05 after analysis of your document

What you see is a logical consequence of your “misuse” of empty paragraphs to achieve vertical spacing. You have the following sequence with every paragraph styled Word Heading:

 (empty paragraph)
 AFTER ALL WE CAN DO
 (empty paragraph)

Therefore when you leave this block, the latest known Word Heading paragraph is the last empty paragraph. It will be used after next page break, resulting in an empty content of the header.

The fix is quite easy: set all your needed vertical spacing inside the definition for style Word Heading, Indents & Spacing tab, spacing above and below paragraph. After that, remove the empty paragraphs.

Note 1: as a general rule, always customise the paragraph style definition to include the spacing above and below. Using empty paragraphs for that will play bad tricks on your back, as demonstrated here. Also, with a paragraph style, you can change the spacing for a single location and it will apply immediately on all occurrences of said paragraph style.

Note 2: you spaced one of your paragraphs with a line break (Shift+Return) which is not the same as a paragraph mark (Return). This resulted in a space added before the title in the TOC.

I was able to insert a field on page 2 and reference it the appropriate heading text from page 1. Now, three pages later on page 5, I want the field to reference a different heading text from page 4, but when I do that, it also changes the reference on pages 2 through the end of the document.

The only way I’m able to get a new heading on page 5 is to insert a manual page break where the text flows onto page 5 and then assign to that page a new page style and then insert a new field into that page style that references the text from page 4. But I don’t want to do that because then text will then no longer flow seamlessly from page 4 to page 5.

According to the Writer manual on page 382 “A cross-reference field in the header of a page picks up the first heading of that level on the page…” That appears to be false. the cross-reference field picks up the header I assign to it. I don’t see any option that allows me to insert a cross-reference that displays the first header on a page.

Caution! There are two ways to reference a heading. The first one, you seem to have used this method, uses a specific heading selected in Cross-reference tab. This will be a frozen reference to the heading. The second one is set from the Document tab and defines a dynamic reference to the “current” heading active at the beginning of the page.

If you still have difficulty configuring your header and its field(s), attach a sample file (3-5 pages) to your question and I’ll look at it.

I did as you instructed. Now, it shows a chapter name in the page header, but on the page that follows a new chapter heading it then shows only a grey field instead of showing a new header. See the document I attached above.

Yes, of course! That all makes sense. Also, I was trying to figure out why I had that extra space before that TOC title but couldn’t figure it out. I will revise the document accordingly and get back to you. Thank you! You rock, mister!!

It worked, it worked, it worked!!! You!!! You’re the man! You’re totally the man…woman…whatever you are, you’re totally it. If you lived in Austin Texas, I’d buy you lunch. Thank you!!! That’s actually easier than what I had to do with Microsoft Word to get that result.

Thanks for providing feedback. May we ask for a little more?

If you solved your case by working out of this answer, click the “tick bullet” by the answer to confirm that the issue is solved. It won’t buy ajlittoz lunch, but it adds a little to their karma.

It will also tag the issue as solved on the front page, which helps the helpers to filter out the cases which do not need attention, and it helps other seekers towards enlightenment.

I was looking for that but didn’t know where it was. Thank you for pointing it out.

See the attachment of some sample pages.