Writer: Table of Contents bookmark displaying incorrectly in export pdf

Good day, I’ve been working on my book for a over a year now and am currently in the editing phase. I’m using Libreoffice Writer and the document is in the .ODT format. My issue lies in the bookmarks and chapter headings, specifically the way they display when I convert the file into a .PDF. Specifically, the Table of Contents chapter always ends up at the bottom of the navigator and ends up displaying incorrectly, despite it appearing fine in Writer itself.

Case in point:


In addition, the Table of Contents doesn’t just stay at the bottom of the bookmark list, but also has every other heading and title underneath it, making PDF navigation somewhat cumbersome.

Additional information:
Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: bffef4ea93e59bebbeaf7f431bb02b1a39ee8a59
CPU threads: 6; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-GB (en_GB); UI: en-GB
Calc: CL threaded

I don’t understand your need to bookmark headings. If you use appropriately the Heading n paragraph styles, your chapter headings are automatically marked for hyperlink generation in the TOC.

Adding bookmarks on the headings is overkill.

You clipped the screenshot (eliminating the status bar) so that we don’t know the page number for the TOC. Is it located between “Creadits” and “Appendix A” (unlikely according to the page numbers)? But it also shows at top of Headings.

It is usually a bad idea to style the TOC heading in such a way it is also attached at an outline level (you create a recursive situation when the TOC is automatically generated).

IMHO, you should let the PDF export filter deal with the Heading n paragraph styles to build the PDF bookmarks from the hyperlinks in the ODT (these hyperlinks can be automatically generated if your document is correctly styled).

First of all, thank you for your feedback. I eliminated the bookmarks since, well, they were indeed excessive and didn’t fix the problem.

Anyway, I think earlier I made the mistake of changing the “Table of Contents” heading style to “Chapter Heading” style, which would make it show up in the top of the hierarchy. That was probably what caused the recursive loop bug that I’m currently stuck with. I deleted and re-created the the Table of Contents. Now the page looks something like this:

Then I once again tried to export a lossless .pdf file The result is the same, except the Table of Contents is not displayed in the navigation panel and the Credits chapter has every Index link listed under itself. I forgot to mention, but this is a problem that I didn’t have on the previous Libreoffice version. The last version of Writer had plenty of other bugs, but the PDF export one is something that just appeared after the last update.

Took a thorough look at it again. The problem seems to be not in the table of contents, but in the way the headings are arranged in the PDF creation process. I, naturally, formatted the documents so that the heading styles formed a hierarchy of Chapter Title > Heading 1 > Heading 2 > Heading 2, etc. That works fine when navigating the document, but for some reason everything after Heading 2 in the PDF gets thrown at the bottom of the panel.

Maybe this will give anyone willing to help a clue.

I don’t know if this is a possibility but if the chapter headings are in frames, possibly decorated for effect, then those pdf bookmarks will appear at the beginning of the pdf bookmarks list, see tdf#95239

@EarnestAl you probably pinpointed the cause. Frames have no relationship with main text flow. The order in which frame contents is considered relative to main text is unspecified because frame contents are supposed to be independent sub-documents, and consequently not constrained by some ordering rule.

I suppose that the simplest workaround is to put the Table of Contents into a frame as well so all headings are outside the main flow

That’s likely the cause. I’ll tinker around with it.

Unfortunately the frames were causing issues throughout the layout process, as they would fight with the title hierarchy. Now the issue is finding a way to fix that without changing the look of the book too much. Thanks a lot.

Avoid frames as much as you can if they don’t make sense. Frames are supposed to contain independent sub-documents. Mastering them is expert-class skill. This requires correct configuration of frame styles and absolutely no direct formatting on them (even innocent-looking moving the frame with the mouse) because frame styles are more “fragile” and sensitive than the other style categories.

Your headings are part of the main flow and must remain in it. Please describe why you chose frames for your Heading 2. @EarnestAl hinted at decoration. This can be done either as an Area attribute in the paragraph style, an image anchored at the heading (with a specifically crafted frame style) or in special cases by tweaking a list style.

Apparently, you don’t use chapter numbering, consequently using a small (fixed, constant) image for all your Heading 2 is possible, with the advantage that the image is automatically added.

You can also create an AutoText entry to pre-set all these elements when you add a new Heading 2.

1 Like

Tinkered around with it and, yes, that is indeed the problem. Thanks a lot you saved me a lot of trouble.

Lesson learned: Do not use frames to store important information such as document structure. I’ll try to think ahead next time I create a Writer template.