How to reset heading context?

A field in the header can be used to repeat some heading.

The page heading context is computed at top of every page by looking up the state of the first line of text. It is a kind of “back-scanning”(+) to discover the most recently used paragraph attached to an outline level. Then “back-scanning” continues with one-step shallower level until level 1 is reached. At the end of this “back-scan”, we have the collection of active headings and they can be inserted with ad hoc fields.

(+) I have no idea about the exact algorithm used, so don’t take my description too literally.

This is fine most of the time. But I stumble on a “special” requirement. The document has the following structure:

1. Level-1 heading
Text for level-1 argument

   1.1. Level-2 heading
   Development of level-2 topic

Back to a second level-1 argument

In this schematic structure, the level-2 block behaves like some sort of list [item] expected to be also part of the TOC with heading consistent numbering, i.e. not a numbering for an independent list.

Header should display the most current “relevant” heading. This is done by requesting level-10 heading. Automatic fallback of the heading field engine ensures this (if level 10 is not found, try level 9; if level 9 is not fount, try level 8; …; if level 1 is not found, return "void).

Everything works fine up to the paragraph “Back to a second level-1 argument”. The specification calls for “relevant” heading. There, heading for level 1 is expected. But the standard algorithm returns level 2. This is not a bug.

How can I handle this very special requirement? How can I tell Writer I demote my context to some level? What I’d like to is to flag the beginning of “Back to …” as being now in outline level context n instead of the one implied by the standard algorithm?

LO 24.8.6.2, Fedora 41 with KDE Plasma desktop, .odt

I guess you do your “Heading on the same line as paragraph” workaround with a virtually invisible field at level 1. It involves some effort though every time you want to revert to level 1
The sample has character style Hidden with Font 2 pt, Transparency 98%
RevertToHeading1v2.odt (17.0 KB)

Or reset Hidden style in Fonts and Font Effects and then just tick Hidden. This will remove the second part of level 1 from the TOC but leave the level heading in the headers

1 Like

@EarnestAl Very simple indeed once you focus your mind in the right direction. Thanks a lot. I elaborate the method in an answer.

The simplest method to achieve “heading context reset” is to repeat the desired heading when argumentation resumes.

For maximum versatility, I choose to duplicate Heading 1-9 as Revert H1-9 (there is no need to duplicate Heading 10 because there is no higher level). I do this with right-click on the style and New. The new styles inherit all their attributes from the built-in one. I add Hidden attribute in Font Effects tab. In order not to disturb too much screen display, it is possible to decrease spacing above and below but this is not necessary for the final result.

Contents of Revert Hn paragraph is a cross-reference to the desired heading.

How does it work?

Since Revert Hn is attached to an outline level, the scanning algorithm considers it is a member of the outline skeleton. Attribute Hidden is not taken into consideration by the algorithm.

This repeated heading is not collected into the TOC because the style has attribute Hidden. Therefore, the TOC is not changed.

This trick relies on the discrepancy of Hidden handling between heading context computation and TOC collection. If the discrepancy is removed in future releases, a more complicated trick will have to be used, based on steganography like having a paragraph in 2pt with foreground colour equal to background.

Once again a big thank to @EarnestAl