# How to create a ToC only for content under Heading 2?

Greetings,

I am making a personal encyclopedia with many articles, much like a Wiki but inside a single text document, and I have a problem concerning headings and ToCs on LibreOffice Writer 6.1. Here is what I am trying to do:

This is what I have on page 2. This is a ToC set for the entire document that evaluates up to level 2. It shows the sctions of the entire encyclopedia and the articles under it:

1. Introduction
2. Articles
2.1 ENGLISH
2.2 FRENCH


Now, what I need are ToCs under each articles that display their content, and only their content. So, as an example, under the heading "2.1 ENGLISH" I would like to have a ToC that looks like this:

2.1 ENGLISH
2.1.1 History
2.1.2 Phonology
2.1.2.1 Consonants
2.1.2.2 Vowels


Much like you would find in a Wikipedia article. But, when I create a ToC under "2.1 ENGLISH" (or any other Heading 2) and set it for chapter I get:

2. Articles
2.1 ENGLISH
2.1.1 History
2.1.2 Phonology
2.1.2.1 Consonants
2.1.2.2 Vowels
2.2 FRENCH
2.2.1 History
2.2.2 Phonology
2.2.2.1 Consonants
2.2.2.2 Vowels


So, from what I understand, the ToC counts Headings 1 as chapters. I would like it to count Headings 2 as chapters, so I can end up with my second exemple and not the last one for each article.

(I don't think I was clear/precise enough before, I hope it's better now. I'm sorry if I'm a bit slow about it, I am quite new to LO and haven't yet delved into its features.)

edit retag close merge delete

Looking at your first level, you have 1) Intro, 2) Articles. Have you some 3), 4), … parts?

Similarly, is your second level limited to English and French?

Provided the global structure is quite restricted to a simple "skeleton", I potentially have a solution.

( 2019-04-11 12:03:26 +0200 )edit

Sort by » oldest newest most voted

I assume you succeeded in creating the per-chapter TOC and that the illustration in your question is for the global TOC in page 2, i.e. you presently have

# 2. Articles

## 2.2 FRENCH

### 2.2.2 Phonology

in the FRENCH article, i.e. without the 1. Introduction.

If this is not the case, the first step is to create the per-chapter TOC.

The problem here is LO Writer only considers a higher level limit and always includes levels 1, 2, etc. up to the user-set higher level. There is no built-in lower-level to start collecting TOC entries. I suggest the following workaround.

Define a paragraph style with name None:

• right-click on Default style in the side style pane (F11) and give it name None in the Organiser tab
• in Indents & Spacing tab, make sure above and below paragraph spacings are set to 0
• in Font Effects tab, check Hidden so that the level won't show up not occupy space

When you create your chapter TOC, (or after right-click on it and Edit index), go to the Styles tab. There you can customise the style association between heading levels and TOC levels:

• in the Levels column, click on *Level 1 [Contents 1] to select it
• in the Styles column, click on None to select it
• the < button between the column is now enabled, push it to replace Content 1 style with None

Repeat for the other levels to eliminate.

Refresh the TOC. You're done.

Note that level collection is unaltered, you just make the undesirable levels invisible.

(Improved with fix by @ThomasEvenor)

EDIT - 2019-04-11

With a better understanding of the question, this is what I arrived at:

It is only a demo which has inaccuracies: global TOC does not contain level-2 entries, numbering of real articles (level 3) do not restart at 1, styles have not been tuned.

Note the variants in the chapter TOCs: the first one does not include levels 1 and 2, while I inserted them in the second chapter TOC as a reminder, in case this is useful.

Answer my questions in the comment below your question and I'll improve my demo and provide a new answer.

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!

more

All right, I tried, and it kind of works. But, as I keep adding headings anywhere in the doc it makes the space between the per-chapter ToCs and the articles content bigger. So I end up with page-long blank spaces in the middle of the articles.

( 2019-04-11 10:40:33 +0200 )edit

I had not the right test case. I'm working on it now

( 2019-04-11 11:56:04 +0200 )edit

I found a way!

After doing everything Ajlittoz said I ended up with blank spaces in my ToCs. To get rid of them:

I right-clicked on the None paragraph style I previously created, pressed Modify, then I went in the Font Effect tab and ticked the "Hidden" box. The blank spaces then disapeared and everything is just as I wanted!

Thank you very much for your help!

more