Add/Remove heading from Table of contents via style

How do I setup a paragraph style to appear or not in the table of contents?
E.g. I want the “Heading 1” style to not be recognized by the indexer for ToC anymore.

Constraints:
Please don’t tell me to use or not use the “Heading X” style. This is not the question and does not solve the problem.

For reference, the concrete problem at hand:
I’ve created a numbered heading paragraph style for my Appendix section. It inherits from “Appendix”. For some reason:

  1. These headings appear in the table of content, while they shouldn’t
  2. They (= these appendix headings) appear wrongly: Level 2 headings have the indentation for level 1 headings.

E.g. I want the “Heading 1” style to not be recognized by the indexer for ToC anymore.

IMHO, this is not possible.

Please don’t tell me to use or not use the “Heading X” style.

It is a pity that you want to limit your knowledge horizon.

…and does not solve the problem.

Sometimes it is helpful to describe the actual problem, because it can suggest possible approaches to solutions.

Thank you for looking into this!

IMHO, this is not possible.

Sounds like a severe problem with the ODT spec :frowning:

Please don’t tell me to use or not use the “Heading X” style.

It is a pity that you want to limit your knowledge horizon.

I don’t understand that comment. Refraining from using Heading X will (IMO) limit my “knowledge horizon”, as I would just run away from the actual problem.

Sometimes it is helpful to describe the actual problem, because it can suggest possible approaches to solutions.

I’ve created a numbered heading paragraph style for my Appendix section. It inherits from “Appendix”. For some reason:

  1. These headings appear in the table of content, while they shouldn’t
  2. They (= these appendix headings) appear wrongly: Level 2 headings have the indentation for level 1 headings.

To remove a Heading n style from the TOC hierarchy, open Tools>Chapter Numbering, Numbering tab. Set Paragraph style: to [None] or the style you want at this level.

I wouldn’t recommend following this venue. Your goal is not obvious. You seem to describe a document with regular chapters (and the Heading n family is perfectly fit for that) and appendices. You didn’t tell if your appendices are numbered the same as the chapters (e.g. after last chapter 11, first appendix is 12) or with a different sequence (e.g. after last chapter 11, first appendix is A).

In the latter case, you must create your own list style for alphabetic numbering or numerical numbering if you restart from 1 (important: use a dedicated style for this to avoid interactions with lists; in other words, if you have no list with built-in Numbering ABC, you can use it for your appendices, otherwise create a similar list style to avoid interactions between lists and appendices).

You must also create a paragraph style family for all the levels of your appendices. To have them listed in the TOC, these styles must be assigned to some Outline level: in Outline & Numbering tab of the paragraph style definition. Don’t forget to link the style to the list style through Numbering style: for automatic numbering.

Also, when typing, custom chapter numbering is not automatically associated with the outline level declared in the paragraph style. The text must be forced to the appropriate level by typing Tab at head of the heading (0 for level 1, 1 for level 2, n-1 for level n). If your heading is too deep, you can correct this with Shift+Tab.

Indentation properties:

  • for unnumbered heading, adjust Indents & Spacing parameters in the paragraph style
  • for numbered headings: these properties are controlled from the list style

Thank you very much for the exhaustive information!

To remove a Heading n style from the TOC hierarchy, open Tools>Chapter Numbering, Numbering tab. Set Paragraph style: to [None] or the style you want at this level.

Thank you very much! I think - generally - this is the answer to my question. However, in my case it does not seem to work.

Explanation:

  • I use the regular Heading 1, Heading 2, … styles. They should appear in the table of contents. So it’s ok to have them set up in Tools>Chapter Numbering ....
  • I created a custom style for the appendix, I called it AppendixHeader. This style is inherited from None at the moment. It is not related to the Heading styles. However, it shows up in the table of contents. This style uses Outline list style, which creates an appearance like below.
Appendix A [title]
A.1 [title]
A.2 [title]
Appendix B [title]
B.1 [title]
B.1.1 [title]
...

I would say - judging from what you wrote - my appendices should not appear in the TOC.

Perhaps I should mention the following:

  • Initially my AppendixHeader was inherited from Appendix (default style), which is inherited (by default) from Heading. I later changed the inheritance settings my AppendixHeader style to Text Body and even later to None. Perhaps there lies the reason why it was shown in the TOC initially. And what I’m experiencing after the inheritance change is a bug in writer…

You can derive the Appendix heading from any style, including Heading, what will or won’t get it in the TOC is what you enter in Outline level on the Outline & List tab of the paragraph style dialog box. Level n (n in 1-9) will get it in the TOC, Text body will exclude it.

The appearance in TOC is controlled by Outline level in Outline & List tab of the paragraph style.

Numbering your appendix styles is dont with a list style, presumably your Outline list style.

Changing the inheritance may mess up TOC inclusion, depending on whether you overrode the setting in a derived style or not. That is, the topmost style in the hierarchy usually imposes its behaviour on its descendants.
It is difficult to tell without looking at your styles.

I should’ve done this earlier: Here’s a test document with my styles:
TOC_testdoc.odt (18.7 KB)

Not a solution, should be in a comment.

I guess now I finally understood what @ajlittoz @anon87010807 were talking about regarding Outline & Numbering.

Thank you very much for the help on this matter!

Now that I understand the specification, I can suggest a solution.

  • Chapter headings end up in the TOC
  • Appendix heading look the same as chapter heading but are not listed in the TOC the TOC

To ensure appendix headings will always have the same appearance as the corresponding Heading n, create them by inheritance: right-click on Heading n in the side style pane. Don’t modify any attribute (+) except Outline level in Outline & List tab and attach a dedicated (=) Numbering style in the same tab.

(+) When no attributes are modified, the style always remains in sync with its ancestor. Any change in the ancestor is automatically forwarded. Caution! “no change” is not the same as setting an attribute then resetting it to, seemingly, revert to the “untouched” state. You changed it and it will remain as you changed it. The only to revert to “inherit” state is to press the Reset to Parent button (Standard prior to 7.2.x).

(=) If you have numbered lists in your document, it is of utmost importance to number your appendices with an independent list style otherwise list and appendix numbering will interfere with each other.

With the above configuration for your appendix heading styles, you create a paragraph style suited for numbered lists. However, custom lists in Writer have not the same user-friendly property as Heading n. Assigning a Heading n to a paragraph automatically sets it at level n in the hierarchy.

When you assign one of your appendix styles, the paragraph is set at level 1 of the list. You must manually move it to the adequate level for the number to be formatted as you expect. Put the cursor at the beginning of the heading and press Tab n-1 times. If you inadvertently pressed too many Tab, press Shift+Tab to decrease list level.

In your sample file, all your appendix levels are formatted the same (AppendixHeader) which doesn’t mimic what Heading n does.

1 Like