Bug 152075 - Writer: TOC for chapter should start at current level+1, not current level
Summary: Writer: TOC for chapter should start at current level+1, not current level
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.2.3 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: TableofContents-Indexes-Dialog
  Show dependency treegraph
 
Reported: 2022-11-16 19:41 UTC by ajlittoz
Modified: 2023-02-18 01:18 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Chapter TOC with "duplicate" chapter heading (14.19 KB, application/vnd.oasis.opendocument.text)
2022-11-16 19:41 UTC, ajlittoz
Details
TOC on left page with chapter semingly starting on right page (21.81 KB, application/vnd.oasis.opendocument.text)
2022-11-20 10:50 UTC, ajlittoz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ajlittoz 2022-11-16 19:41:53 UTC
Created attachment 183633 [details]
Chapter TOC with "duplicate" chapter heading

Version: 7.4.2.3
Build ID: 40(Build:3)
CPU threads: 4; OS: Linux 6.0; UI render: default; VCL: kf5 (cairo+wayland)
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded

Just upgraded to 7.4 series and testing new features.

TOC for chapter has been improved to collect entries "starting with current level instead of hard-wired 2".

IMHO, this is wrong because it also lists the heading for the current chapter, duplicating it as the chapter-TOC is very commonly inserted immediately after chapter heading. Attached file shows the duplication.

Previously (pre-7.4 releases), chapter level was considered 1 and headings collection started with 2 (=next level after 1).

Please start collection at next level after current level.
Comment 1 Roman Kuznetsov 2022-11-17 19:42:12 UTC
We discussed the same question on our Russian forum and still no have single PoV

My PoV was to add another control for it and the we'll have something like:


For: Chapter   Start from level [2]     Evaluate up to level [10]

                  ^^^^^^^^^^^
                  to add this
Comment 2 ajlittoz 2022-11-18 09:35:37 UTC
(In reply to Roman Kuznetsov from comment #1)
> My PoV was to add another control for it and the we'll have something like:
> 
> 
> For: Chapter   Start from level [2]     Evaluate up to level [10]
> 
>                   ^^^^^^^^^^^
>                   to add this

Your proposal gives more control to user and is therefore better. It is indeed an enhancement, while I was only proposing a fix for something I consider a bug (and is not consistent with the previous hard-wired start at 2).
Comment 3 Heiko Tietze 2022-11-18 15:01:44 UTC
(In reply to Roman Kuznetsov from comment #1)
> For: Chapter   Start from level [2]     Evaluate up to level [10]

Sounds reasonable. But I'd not arrange it in one row as the 'evaluate up to' option does not depend on the start level. I also wonder what users expect for the start. Is it the level 1,2,3... or the actual number like 3.1 or 4. Start from level 2 would still return 3 in the example.
Comment 4 ajlittoz 2022-11-18 17:32:52 UTC
(In reply to Heiko Tietze from comment #3)
> (In reply to Roman Kuznetsov from comment #1)
> > For: Chapter   Start from level [2]     Evaluate up to level [10]
> 
> […] I also wonder what users expect
> for the start. Is it the level 1,2,3... or the actual number like 3.1 or 4.
> Start from level 2 would still return 3 in the example.

As we can never guess what a user would like for a specific document, how would the following (nonsensical ?) scenario be handled?

Document has structure like:

1 Heading 1
1.1 Heading 2
Some text
2 Heading 1
2.1 Heading 2
Some text
2.2 Heading 2
<<-- "chapter" TOC here with request start from 1 (instead of more common start from 3)-->>
2.2.1 Heading 3
2.2.2 Heading 3

With a request to start from 1, it is clear that user wants to repeat 2 Heading 1 and 2.2 Heading 2 in his chapter TOC (without 1 Heading 1 and its sub-tree, nor 3 Heading 1 with its sub-tree and subsequent. If "Start from level" is allowed to be unconstrained, it complicates entries collection because a distinction must be made between shallower levels (retrieve only from current "context" just like fields would do) and deeper levels (where usual engine can be used).

So, the "Start from level" is the first level to include in the chapter TOC, not the designation of the level where the TOC is inserted in the document.
Comment 5 Mike Kaganski 2022-11-19 11:11:38 UTC
There are two ~orthogonal aspects:
1. Creation of a ToC *for the current part of the document*;
2. Inclusion of the entry that defines the current path into the ToC.

IMO, the "flexible" proposal from comment 1 makes little sense. It is unreasonable to expect both levels higher than current in the local ToC, and also starting from levels lower than the immediate sublevels of the current one. So: when you have a section 2.4.6, and create a ToC under it, you might want to have 2.4.6 in the generated ToC, or you may want to have only 2.4.6.1, 2.4.6.2, ... . But you would not want entry 2 there, nor entry 2.4. In a strange situation when one could want these, one can always create cross-reference fields before the ToC, with specified levels. And one would not want the ToC to only contain 2.4.6.1.1, without 2.4.6.1 itself, in the ToC.

All the extra situations are implementable using specific style assignment to the ToC, instead of basing the ToC on outline. One can even implement the layout requested in the mentioned Russian forum topic, using existing tools; bit since the requests to have ToCs for levels below 2, and also to omit the "starting" level, are really common, these *two* specific needs should be addressed in dedicated UI, but not an unlimited flexibility.

So IMO:

1. The "Chapter" element must mean "current section" - which is already implemented in master, right?
2. There should be a [] Include current "chapter" into the ToC.

The flexible "from level" selector is overkill, and is bad (would result in poor UX).
Comment 6 Mike Kaganski 2022-11-19 11:16:45 UTC
(In reply to Mike Kaganski from comment #5)
> 1. The "Chapter" element must mean "current section"

Sorry for the use of misleading "section" word there - it is meant "current part of the document outline". I have no good proposal for the UI term - but I feel "chapter" term, still used in the "For:" dropdown in the dialog, to be inadequate for the newly implemented "current level" behavior.
Comment 7 [REDACTED] 2022-11-19 11:43:35 UTC
Having a TOC right below a chapter title with the chapter title included seems redundant to me. But there are books where a new chapter starts on a right page, and the TOC for that chapter sits on the opposite (left) page. In that case, including the chapter title in the TOC would make perfect sense. Unfortunately, you wouldn't be able to include a chapter TOC just before the start of a chapter in the present implementation. I played a bit with inserting the content of a single chapter in a section, wondering if you can make a TOC for just a section of a document. It turns out that you can't, but maybe it's an idea to allow TOCs for sections.
Comment 8 Mike Kaganski 2022-11-19 12:00:14 UTC
(In reply to Peter Roelofsen from comment #7)

Having the described layout (Chapter ToC prior to the chapter itself) would possibly best be implemented by the third element in the "For:" drop-down (next to "Entire document" and "Chapter"), like "Specified chapter", giving a choice similar to what "Cross-reference"->"Headings" field allows. That is a separate issue, that needs an own proposal. This is off-topic here.
Comment 9 ajlittoz 2022-11-20 10:48:35 UTC
(In reply to Peter Roelofsen from comment #7)
> Having a TOC right below a chapter title with the chapter title included
> seems redundant to me. But there are books where a new chapter starts on a
> right page, and the TOC for that chapter sits on the opposite (left) page.
> In that case, including the chapter title in the TOC would make perfect
> sense. Unfortunately, you wouldn't be able to include a chapter TOC just
> before the start of a chapter in the present implementation. I played a bit
> with inserting the content of a single chapter in a section, wondering if
> you can make a TOC for just a section of a document. It turns out that you
> can't, but maybe it's an idea to allow TOCs for sections.

This can already be done. You have to cleverly customise your paragraph styles and cheat a bit.

The Heading 1 is entered before the chapter TOC to create context. It is formatted as Contents 1 (but take care about tabs because you can't, or rather shouldn't, insert a page number because it would mess up the rest of the layout).

The chapter TOC is inserted using Additional styles so that you exclude Heading 1 which is just above the chapter TOC. You list in these styles all Heading n, save the level you are in and lower.

I use a new paragraph style Offset Heading 1 which is formatted as the original Heading 1 so that it looks exactly as a chapter start. It is filled with fields for chapter number and title. This paragraph style is at Body Text level in order not to disturb the outline.

See
Comment 10 ajlittoz 2022-11-20 10:50:34 UTC
Created attachment 183685 [details]
TOC on left page with chapter semingly starting on right page
Comment 11 ajlittoz 2022-11-20 10:52:50 UTC
(Sorry for pressing the wrong links while commenting and attaching a sample file)

In the sample file I didn't use page breaks but you have the idea behind the scheme. Study carefully the changes in Heading 1 and the new style Offset Heading 1.
Comment 12 Heiko Tietze 2022-11-24 09:21:47 UTC
The topic was on the agenda of the design meeting but we didn't came to a conclusion.

To summarize: the request questions the fact that a chapter numbering inserted behind the H1 would include this item too. The expectation is to start with the next level after the current.

Roman proposed to make the start point configurable. But whether we let users define the level (which would IMO be a very difficult to understand) or to allow setting the exact outline - there is actually no use case that comes in mind which would be solved.

Mike said in comment 5 that we may add "[] Include current "chapter" into the ToC". Makes sense if the ToC follows on another page, for example, as Peter pointed out in comment 7.

So let's do it.