Writer ToC starts at §2 but hover shows §1

Hello,

I'm using Writer 5.2.5.1 for a document using in which I use
outlining for numbering and a table of contents.

The problem I have is that while the first Heading 1 instance
correctly gets numbered §1, the ToC displays it as §2 *but* when
I hover over the entry, I am told to ctrl-click to go to §1. So
somewhere inside, LO seems to get confused.

Please see the attached screenshots for the ToC with the hover text,
as well as the setting in the index dialogue. The preview looks
exactly right.

Am I doing something wrong?

also sprach martin f krafft <madduck@madduck.net> [2017-03-02 11:07 +1300]:

Please see the attached screenshots for the ToC with the hover text,
as well as the setting in the index dialogue. The preview looks
exactly right.

Since this list strips attachments, here they are:

  http://scratch.madduck.net/lo-toc-off-by-one.png
  http://scratch.madduck.net/lo-toc-configuration.png

Thanks,

martin f krafft wrote:

also sprach martin f krafft <madduck@madduck.net> [2017-03-02 11:07 +1300]:

Please see the attached screenshots for the ToC with the hover text,
as well as the setting in the index dialogue. The preview looks
exactly right.

Since this list strips attachments, here they are:

  http://scratch.madduck.net/lo-toc-off-by-one.png
  http://scratch.madduck.net/lo-toc-configuration.png

Seems to work OK for me, with LibreOffice 5.3.0.3 on Windows. Does this happen with every document, or just the one? All I can think to try is right-click within the table of contents and click "Update index" (or via the menu Tools > Update > Indexes and Tables) to see if that resolves it.

also sprach libreoffice-ml.mbourne@spamgourmet.com <libreoffice-ml.mbourne@spamgourmet.com> [2017-03-03 09:48 +1300]:

Seems to work OK for me, with LibreOffice 5.3.0.3 on Windows. Does
this happen with every document, or just the one? All I can think
to try is right-click within the table of contents and click
"Update index" (or via the menu Tools > Update > Indexes and
Tables) to see if that resolves it.

I've tried that, of course.

I also managed to reproduce this in a new document, which I've
uploaded here:

  http://scratch.madduck.net/lo-toc-off-with-outline-numbering.odt
  size:10889 hash:8c39ae6c8da0971b048a76b0f2f1d82703cf2929

The problem seems to relate to (ab)using outline numbering to number
paragraphs, i.e. Level 1 is Heading 1, but Level 2 is associated
with the Text body style (as per suggested solution to my previous
thread two days ago).

Even though there are no instances of either Heading 1 or Text body
before the first header, this seems to throw off display of the TOC
(which the hover-text for links is just fine). So I guess, a bug…

also sprach martin f krafft <madduck@madduck.net> [2017-03-03 10:27 +1300]:

Even though there are no instances of either Heading 1 or Text body
before the first header, this seems to throw off display of the TOC
(which the hover-text for links is just fine). So I guess, a bug…

Maybe #31379

Interesting. I can reproduce this on LO Writer 5.1.4.2 using
UbuntuStudio 1604LTS and with only Heading 1 style as Level 1 and Text
Body style as Level 2 to get the numbered paragraphs.

Using F12 to toggle paragraph numbering on/off causes ToC to come good
when Paragraph numbering is off, bad when numbering is on. Although the
hyperlink in each line of the ToC remains correct and functional, using
'edit hyperlink' shows the change in the text caused by the toggling of
the para numbering. Looks like it is related to the bug you identified.

For short documents, I have long since simply constructed my ToCs
manually rather than use LO's facility. You could do so as a workaround
to help you keep paragraph numbering. Not very convenient though if your
document is lengthy.

[I seem to remember seeing hover-text in the past, but I have lost it now]

Philip

I was going to add my comments to the bug but before doing so, I decided
to repeat the exercise and make another new file to demonstrate the problem.

Without success ... this second time it behaves perfectly with the ToC
just as one would wish regardless of whether the paras are numbered or
not. So clearly there is some other factor intervening.

Closer examination shows that in this new file, I have an empty Text
paragraph between the ToC and the first Heading1. This is because, I
first created a Heading1, then 3 Text Body paras, then another Heading1
and 3 text paras. In other words, the body of the document. Then, in
order to insert the ToC at the top of the first page, I placed the
cursor at the beginning of my first Heading1 and hit return. This left
me with an empty H1 para which I converted to Text Body to be sure no H1
occurred before Chapter 1.

With the cursor at the top of the page (ie in the empty Text para), I
inserted the ToC.

This empty Text para is the key to the ToC showing correct numbering.

If I place the cursor in any of the document's Text paras and toggle
numbering on. The ToC shows correctly (after updating, of course).

If I place the cursor in the empty Text para (just beneath the ToC) and
toggle numbering on. This para takes number 1.1 and the ToC shows
incorrectly. Delete the 1.1 numbering and update the ToC and it displays
correctly.

Add a bit of text in the empty para and update the ToC and you'll see an
extra line created before the first H1.

Not at all evident unless you have non-printing characters displayed.

Philip

I should have added that if the empty text para between the ToC and the
document text is deleted, then the ToC displays incorrectly. So for
Martin to have his work behave nicely, I suggest he tries to add an
empty text para right under the ToC.

Philip

also sprach Philip Jackson <philip.jackson@nordnet.fr> [2017-03-04 06:01 +1300]:

Closer examination shows that in this new file, I have an empty Text
paragraph between the ToC and the first Heading1. This is because, I
first created a Heading1, then 3 Text Body paras, then another Heading1
and 3 text paras. In other words, the body of the document. Then, in
order to insert the ToC at the top of the first page, I placed the
cursor at the beginning of my first Heading1 and hit return. This left
me with an empty H1 para which I converted to Text Body to be sure no H1
occurred before Chapter 1.

Great analysis. I can confirm that this works in my case too. Thanks
for updating the bug report, too!