Headings outside the main body are shown out of order

I create a new document and enter some sample text in Text Body. I add a Heading 1 and I add a Heading 2, I then insert a frame and add a Heading 4 and some text. I then do a Manual Page break and add a Landscape page with Header on. Into the header I enter a Heading 5. I create a Table of Contents using the default settings.

I now see in Navigator that the lower level 4 & 5 Headings come before the body of the document and before higher level Headings, although in the TOC they are in correct order.

The incorrect order is reflected in Bookmarks when exported as PDF, and the Headings are promoted to the same apparent level as higher level Headings

There probably isn’t a rational use of a Heading in a header but I included it as it exhibits that behaviour. How can I use Headings in a frame and keep them in page order? Or should I just create another style and add that style to TOC? Cheers, Al

BookmarksAlTest.odt

Version: 7.1.5.2 (x64) / LibreOffice Community
Build ID: 85f04e9f809797b8199d13c421bd8a2b025d52b5
CPU threads: 8; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: en-NZ (en_NZ); UI: en-GB
Calc: CL

2021-07-27 07:54 UTC

I wanted to include a point not directly related to the current text but needing a short explanation of another method not under discussion so I inserted a frame out of the text flow. I wanted the heading of the side text to appear in the table of contents because, being not directly related to the Heading for the main text, it wasn’t obvious where to find it again.

In the end I went back and removed the frame and put a paragraph border around the breakout text to try and show it wasn’t part of the text flow but it emphasises the text rather having it as a box to one side.

I apologise for the two red herrings: the accidental blank Heading 1, and the Heading in the header which I created while playing with a document to try and find out why the Heading in a frame problem occurs. Cheers, Al

Position of the frame’s heading likely should be fixed (file a bug report for that). But putting headings to headers is conceptually wrong, and you simply should not do that. You put it out of text flow, to a repeated part of document - i.e., into page style.

A nitpick: there’s a “Heading 1”-style empty paragraph under ToC on the first page.

The border or some kind of paragraph background were the ideas I had in mind. They don’t break text flow and give sufficient visual emphasis to denote contents difference.

Don’t be sorry for your “red herrings”. Sometimes they are really useful to uncover weird behaviour or clarify obscure points in the documentation. And last but not least, everybody makes errors. The added-value of errors is when people learn from them.

A light grey background without border but with indent might work better. Thanks

Posted as Bug tdf#143569 - Headings outside the main body are out of order in Navigator and PDF

When you insert a frame, you create another text flow with no “geographical” or logical relationship on the main text flow. Then the relative order of contents collected to build tables is unpredictable.

See my answer to question 270540/chapter-numbers-in-frames.

Similarly, inserting a Heading n paragraph in a header or footer is nonsense because a header or footer is a non-positioned attribute of a page style. It is computed once and cached in an auxiliary page style buffer and copied on every page when needed. Consequently, it is not associated with a well-defined page (when TOC is collected you may get first or last page for this page styles – anyway, this is not specified).

Your document is faulty and exporting it does not cure the created mess.

Edit your question describing what you want to achieve with your framed heading/header heading in “abstract” terms (i.e. don’t suggest a solution; describe the end result) so that other ways may be proposed.

Remark: from the screenshot, you seem to have an empty Heading 1 near the beginning of your document.

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!

Note that frame’s anchor in fact defines relative order of its contents, so in frame’s case, this could be improved.

@mikekaganski: yes but you can still create conflicts which can’t be solved structurally. Example: you are in a Heading 1 part with subordinate Heading 2. You anchor a frame to a Text Body paragraph. Inside the frame you have a Heading 1 and Heading 2. Even if you sort the TOC by anchor location, you’ll get a weird TOC with the frame Heading 1 group “interrupting” the main Heading 1 resulting in an unusual numbering sequence.

It is much better to avoid chapter numbering in frames. Or else, you must use a dedicated style family and collect everything in a separate “TOC”.

@ajlittoz I agree in general. It would also be difficult to have a reasonable ordering for e.g. cases like Heading 3 paragraph having a to-character anchored frame somewhere in the middle, and the frame having e.g. a Heading 1.

However, some improvement here is possible, making use of the natural order of elements in the main text flow (anchor being treated as a special “character”), which would enable reasonable use in cases like the one described by @EarnestAl, without introducing considerable downsides.