Table of contents showing "random" items

I have inserted a table of contents following the instructions here:
https://help.libreoffice.org/latest/en-US/text/swriter/guide/indices_toc.html?&DbPAR=WRITER&System=MAC

It’s not showing what I expect: I want it to show all the list items at level 1 and 2 (I have formatted almost the whole doc using a custom List Style)

I read in this post that “TOC is usually based on styles; start checking the styles”

What style do I need to check? And is there a way of highlighting all the parts of the doc that share one style?

I’ve tried altering the “Include up to level” option in Edit Index, no change.

I want something like this:
Screenshot 2024-11-14 at 15.05.13

I’m getting this - all list levels, but apparently random which items: sometimes it jumps many paragraphs and starts lower down the doc

PS I’ve also tried clearing all direct formatting, no change

It seems that the 3rd level of your ToC is formatted as Heading 3 in your text, probably not in body text (?). For any help upload a sample file.

1 Like

Thanks: I’ve tried Ctrl-A and double click on Body Text , but no change.

Sample file attached.
TOC : headings problem.odt (40.6 KB)

Unfortunately, this is a somewhat confusing simplification. @Wanderer wrote that to not complicate things; but the actual default mode of building ToC is using the outline levels; again, by default, only some styles (namely, heading styles) are assigned outline levels (through heading numbering feature); and thus, in the most common case, checking the styles is a good start.

But the outline levels may be assigned to any style and any paragraph directly. See this:

The “Level 1” style has outline level of 1, meaning that this style is “heading of chapter”.

1 Like

Ah, I see: Level 1 paragraph style <> Level 1 list <> Level 1 outline!

(I think)

Thank you: now I’ve understood there are three types of attribute interacting together.
(After my list list styles query I thought there were just two.)

To keep it tidy in my head, which should I think of as the “foundation” structure, which other attributes modify? @ajlittoz suggested List Style is more fundamental than Paragraph Style. Where does Outline Level fit in the hierarchy?

Or saying it another way, when I’m setting up my document, in which area of the many settings do I start?

((Joking apart, I really think the UX is the only thing between LO and a total global takeover - once you understand it, everything is so much more logical and powerful than MS $ffice))

Your document has been created with M$ Word or edited in some way by Word. And some “style pollution” has been introduced into it.


The document is plagued with direct formatting and you messed its structure by using practically the same paragraph style Level1 for logically unrelated paragraphs.


You should restart by sticking to built-in Heading n paragraph styles for the outline.


Be consistent in your use of paragraph styles: for example “Part A …” is Level 1 (+ direct formatting=DF) and “Part B …” is Default Paragraph Style + DF.


Don’t use Default Paragraph Style for your text. This is a “technical” style intended for definition of global typographical attributes shared by all other styles. Customising it has an impact on all others.

You should start by thinking about the structure of your document. What are headings? What are “explanatory” text? Which points are “true” list items?

From this introspection, deduce the needed paragraph style: one logical significance => one paragraph style.

Avoid direct formatting. Other style categories are here to help you: character, page, list. I know, they don’t exist in Word, but they are your friends.

I started with a clean .odt and went from there.
I am cutting and pasting from a M$ Word doc (someone else’s): does that transmit the infection?

I think maybe that quoted comment of yours answers my quoted question: paragraph styles are basic, other things modify paragraph styles?

I’m trying, I really am. :slight_smile: I somehow add it without even intending to (maybe from the other person’s doc I’m copying from.)

From the sound of things, I’d be much better thinking of Writer as LaTeX under the hood, rather than M$ Word that it visually resembles more?

Yes, unless you paste as Unformatted text and redo the formatting with genuine Writer styles.

There are 3 layers of formatting, from deeper to shallowest:

  • paragraph style (contains a “default” character style)
  • character style
  • direct formatting (DF)

Each upper layer overrides deeper levels when the same setting is defined in both layers: DF overrides character style which overrides paragraph styles. Details are a bit more complicated when you want to understand why some types of DF are not cleared by Ctrl+M but this 3-layer model is sufficient to understand conflicts.

I trust you for that. Your document shows a real good start. You need to abstract more your document. This is the most disturbing part when switching from other office suites (it took me a while to develop my own mental model to master Writer).

One innocent-looking DF form is vertical spacing with empty paragraphs. Empty paragraphs don’t carry information; therefore, logically, they should not be present in any text. Their use comes from not knowing about the box model for every “object” in Writer: paragraph (most obvious), character, page, frame, drawing objects, …

From inside out, you have the "contents’ (text or shape) surrounded by padding. Around this, there is a border (which can be 0-width, leading to “interesting” effects though invisible). And you finally have “margins” (this spacing has two names in styles: spacing in the vertical direction, indents in horizontal direction).

Globally this creates a rectangle which is laid out in the “container”. The container can be a page, a section, a frame. The rectangle is an area which becomes unavailable for other objects in the container, causing movable objects to be flushed outside the rectangle.

When you become versed in style settings, you can control the layout and flush algorithm in various ways (to achieve rectangle overlap or on the contrary to cause automatic repositioning of the rectangles).

So, instead of using empty paragraphs (which can move and flush your significant target paragraphs and break your careful manual page synchronisation), customise the “margins”, i.e. spacing above and below paragraph) so that the spacing becomes an intrinsic property of the paragraph (style).

And page sync is achieved with Text Flow properties in style.

Contrary to popular belief, DF is not easier nor “intuitive”. It requires super expert skill to format documents as expected and is a real pain when you want to optimise or tune your layout.

1 Like

Thanks for all that.

A list style is (or can be) a component of a paragraph style?
A paragraph style is not a component of a list style?
A “list style” is really no more than a numbering style (ABC, 123, etc); so font, spacing, indent, etc are all set by the paragraph style?

Completely agree with that: anything beyond a business letter is just so much work you give up and let it look horrible. Although the law firms whose documents I see often seem to have cracked it. Maybe they have an army of W$rd monkeys to sorting it all out for them.

I see that the issue as such is resolved, so you can safely disregard my comment here. Posting my additional findings in case you should have issues at a later time. There is more to documents than what meets the eye :wink:

Some background, things that I observe:

  • The document contains list elements which are assigned outline level in parallel with list level. This is where the “Level x” styles enter the scene.
    Outline levels describe the overall document structure, and is the foundation for the default ToC behavior. List level is separate from this. A list is usually in its entirety a text body element on “outline level zero”. Using the two “level ladders” in conjunction is rarely, if ever, a good idea.
  • You have the builtin “Body text” style and also a separate (custom) “Body” style. This may be confusing if you are unaware of the presence of both.

I suspect that this is the result of pasting content copied from MS Word, as you say. The ToC builder there is more geared to “read your mind”, which sometimes is a good thing, but it allows for (hides) a lot of the structural mess we see in your sample. I first thought that you must have pasted while inside a heading paragraph, but there is more to it than can spawn from that simple situation.

Sort of.
The numbering of paragraph styles is merely a name. Naming a paragraph style “Heading 1” doesn’t place it in the outline hierarchy. Setting a list level for it, also doesn’t. Assigning the Outline level 1 to it, does.

1 Like

This is all very useful - including for someone else new who comes to @mikekaganski 's characteristically concise solution. It is the solution, but it takes some careful reading (which is totally fair work!). This and @ajlittoz 's extra context makes that much easier.

I’m going to start another post for my follow-ups

It can be, there is a tab in the paragraph style called Outline and List you can define an list style to be associated with the paragraph style.

Best to let the table style do the indents or you will have conflicts between paragraph and table style
.
The problem is that there is some odd stuff carried over from Word that can’t be corrected, or at least can’t be easily corrected. Pasting it all into new document as unformatted text and starting again with clean styles is the quickest option.
I used Heading Numbering for the two Heading levels, the rest of the list is List 1 style with associated List style.
TOC _ headings problem113865EA.odt (41.8 KB)

1 Like

The basic unit in Writer is the paragraph. It has typographical and geometric properties. Its typographical attributes are controlled by Font and several other tabs which are the same as those of a character style. Conceptually, this defines a default character style to be applied to the paragraph.

Note that from a theoretical point of view, character and paragraph styles could have been maintained completely separate, but this would have proved not user-friendly (making mandatory definition and repetitive application of mostly the same character style over the paragraphs).

Consider the “default” character style as a permanent decoration for the paragraph, covering ~80% of the use cases. In the remaining ~20%, you find “exotic” decorations like numbering.

Since numbering layout has many complex requirements varying with publications, it is better to describe the properties in a dedicated “style”. Personally, I find that naming the style category controlling numbering list style is not a good idea because it instinctively implies that such a style is a complete description of a list item (paragraph) format and layout. And the availability of built-in paragraph styles with name List n or Numbering n perpetuates the confusion. In addition, these styles won’t give you bullet or numbered lists because there are not associated out-of-the-box to any list style.

List styles describe the properties of the multi-level list counter (yes, every list in Writer is automatically 10 levels deep) and its position relative to the (future) paragraph. Since the numbering rules are rather sophisticated (compared to the simple “rectangular” aspect of a paragraph), the list style will completely take control of the numbered edge of the paragraph (left side for LTR, right side for RTL).

You apply a list style two ways:

  • as “direct formatting” (this a special case of DF you can’t erase with Ctrl+M because this command operates only in the paragraph and character layers; list layer is separate) on a paragraph
  • as “automatic attribute” by associating some paragraph style with the list style (in Outline & List tab)
    Then your paragraph style becomes what laymen understand as “list style”: they apply the paragraph style and it shows up as numbered (or bulleted).

By the way, avoid as much as possible Format>Bullets & Numbering (or equivalently toolbar buttons). It is offered for M$ Word switchers so that they are not upset by the style concept and can (unfortunately) go on with their Word routine. The feature is a one-size-fits-all one and has been tweaked to accept logically independent lists under a single formatting command. This means that many rigorous checks have been disabled to allow for import and edit of Word documents without breaking them.


The list mechanism in Writer is generic (and fundamental). It is used to number headings. Consequently what you know about list numbering can also be used in headings (e.g. an unnumbered item while keeping all other alignments – example: Dedication or Introduction heading). Heading numbering has extra properties, though. A different paragraph style is automatically applied on different levels. The paragraph style associated to a level is automatically assigned the same outline level.

The only difference with ordinary list style is heading numbering is protected against direct user modification (you must do it through Tools>Heading Numbering) and you cannot assign directly this style to any paragraph style to avoid creating a numbering mess (mixing ordinary lists with heading list).

Since heading numbering relies on the standard list mechanism, you can create a user alternate heading numbering hierarchy with a user list style applied on a family of paragraph styles. I use the standard Heading n for numerically-numbered chapters and a parallel Appendix n family for alphabetically-numbered annexes.

1 Like