Bug 129302 - FORMATTING:chapter name field in header does not reflect first chapter in current page
Summary: FORMATTING:chapter name field in header does not reflect first chapter in cur...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.8.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Writer-Header-Footer Fields Authors
  Show dependency treegraph
 
Reported: 2019-12-10 00:19 UTC by VincentYu
Modified: 2023-10-26 17:35 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
3 pages with 1 heading1 and 2 heading2's and header (9.58 KB, application/vnd.oasis.opendocument.text)
2019-12-10 00:21 UTC, VincentYu
Details
Inconsistent "current" level-2 heading on a first page. (9.66 KB, application/vnd.oasis.opendocument.text)
2020-07-21 19:46 UTC, jeanmarczambon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description VincentYu 2019-12-10 00:19:51 UTC
Description:
chapter name inserted into header should show first heading of that level on the page, instead it showed the previous one.

Steps to Reproduce:
1.enter 3 lines of text
2.turn 2nd line into heading level 2 using styles->heading 2
3.add heading, insert->fields->more->document->chapter format->chapter name level->2

Actual Results:
heading on previous page is shown

Expected Results:
should've shown the heading in current page


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 VincentYu 2019-12-10 00:21:50 UTC
Created attachment 156451 [details]
3 pages with 1 heading1 and 2 heading2's and header
Comment 2 VincentYu 2019-12-10 00:25:00 UTC
On Writer 6.0 guide page 382:
Note
A cross-reference field in the header of a page picks up the first heading of that level on the page, and a field in the footer picks up the last heading of that level on the page.

Writer 6.2.8.2 release behaves differently.
Comment 3 VincentYu 2019-12-10 02:43:48 UTC
Version: 6.2.8.2 (x64)
Build ID: f82ddfca21ebc1e222a662a32b25c0c9d20169ee
CPU threads: 2; OS: Windows 6.3; UI render: default; VCL: win; 
Locale: en-US (en_US); UI-Language: en-US
Calc: threaded
Comment 4 AndrewS 2019-12-11 09:13:39 UTC Comment hidden (no-value)
Comment 5 VincentYu 2019-12-11 10:11:09 UTC
It's about showing level 2 chapname on heading when chapname changes on following pages. When a new level 2 chapname appears in middle of page, it only start to show on the FOLLOWING page. It should showup in header of CURRENT page according to the guide. Pls see my attached file for details. It has 3 pages.
Comment 6 VincentYu 2019-12-11 11:42:46 UTC Comment hidden (no-value)
Comment 7 Dieter 2019-12-29 11:26:49 UTC
I confirm, that LO (In reply to VincentYu from comment #6)
> According to writer 6.0 guide page 382
> Note A cross-reference field in the header of a page picks up the first heading
> of that level on the page, and a field in the footer picks up the last
> heading of that level on the page.
> 
> Writer 6.2.8.2 release behaves differently.

I think documentation is not correct enough here. The first line of page 2 of your document belongs to chapter "Heading21". So Cross-reference in header is "Heading21". If you delete the first line, cross-referece will change to "Heading22". So for me everything works as expected, but documentation should be more precise.

=> NOTABUG

Please feel free to change it back to UNCONFIRMRED with a short reasoning, if you don't agree.
Comment 8 VincentYu 2019-12-29 13:41:20 UTC
There are plenty of documents/books(published ones) that show/want to show the first new section on a page in the header. I don't think the documentation is wrong. You are just imposing what you think is the only reasonable choice on the user. At least there should be some flexibility here.
Is there an alternate way to achieve what's stated in the documentation? liking using a custom variable?
Comment 9 Dieter 2019-12-29 13:48:50 UTC
Vinent, I don't like the insinuation in your comment. If I do something for LO, I do tis in my free time and unpaid. No further coment from my side

cc: Design Team for further input
Comment 10 Heiko Tietze 2020-01-06 13:35:24 UTC
Chapter is documented as "the number of the chapter where the referenced target is located.", see [1]. And the ODF defines "If this element is placed inside a header or footer, it displays the current chapter name or number on every page." [2]

[1] https://wiki.documentfoundation.org/images/b/bc/WG6017-Fields.pdf
[2] http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415316_253892949

My understanding of "current" is the same as Dieter's - the chapter to what the first paragraph belongs is taken into the variable.

If you expect some other procedure you would have to answer the question when the header takes what is on the page. You may have 50% of the text in mind but consider also more than one heading on the same page. And other users probably expect the current behavior. I don't see a solution for your workflow.

Last but not least I opened the document with MSO 2016 where all headers show "header22". Probably Word cannot deal with this type of variable (cross-reference has nothing like chapter). But maybe we have a roundtrip problem. Miklos, what do you think?
Comment 11 Miklos Vajna 2020-01-07 09:24:40 UTC
Writer has a chapter field, I think that's a subset of what Word's STYLEREF can do. See e.g. bug 104334 for details.
Comment 12 jeanmarczambon 2020-07-21 19:46:19 UTC
Created attachment 163379 [details]
Inconsistent "current" level-2 heading on a first page.

Hi everyone,

I'm facing the same problem, and I would like to give some pro arguments to the "first-heading-in-page" paradigm (as written in official documention: https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/Writer_Guide/Using_fields_in_headers_and_footers), against the "first-text-node-heading" paradigm (the actual implementation, best described by Kartik Subbarao: https://bugs.documentfoundation.org/show_bug.cgi?id=81012#c6).


1. The first page problem
-------------------------
A typical case is a document which first page starts with different heading levels (see attachment):

   1. Level 1
   1.1. Level 2
   1.1.1. Level 3
   [text]

The "current" level 2 heading is naturally "Level 2", but the header field will show "Level 1" as it is the first paragraph of the page.
The "first-heading-in-page" paradigm would have set "Level 2", as expected.


2. Dictionary comparison
------------------------
The best real world example I can think of, regarding level-2 field in header, is the dictionary habit of referencing first and last entries in a page at the top of that page.
First entry in header is always the first one in the page, even if this entry is not the first text of that page (i.e. when a page starts with the end of the previous definition).


3. This enhancement was once accepted
-------------------------------------
This is a very old request (https://bz.apache.org/ooo/show_bug.cgi?id=16211), which was immediately accepted by the OOo team but that no one ever took charge.


Hoping that this can (calmly :)) reopen the debate...
Comment 13 Dieter 2020-08-09 10:15:39 UTC
I revised my opinion and support the enhancement request. I had a look at CMOS (Chicago Manual of Style 17th Edition) and there you can find, that always the first heading of a page is header.

(In General it would be a great advanteage if there would be the basic rule, that LO is in lne with at least one of the well know style guides. Has that ever been discussed, Heiko?)
Comment 14 Thomas Lendo 2020-08-09 14:27:39 UTC
+1 for this request.

I doubt that this is the first bug report.
Comment 15 Heiko Tietze 2020-08-11 14:54:35 UTC
(In reply to Dieter from comment #13)
> (In General it would be a great advanteage if there would be the basic rule,
> that LO is in lne with at least one of the well know style guides. Has that
> ever been discussed, Heiko?)

We always discuss changes based on standards like the CMoS. Ideally we have several standards and the user can switch between CMoS, APA, IEEE...
Comment 16 QA Administrators 2022-08-14 04:11:17 UTC Comment hidden (obsolete)
Comment 17 Dieter 2022-08-15 07:03:20 UTC
Still present in

Version: 7.4.0.3 (x64) / LibreOffice Community
Build ID: f85e47c08ddd19c015c0114a68350214f7066f5a
CPU threads: 4; OS: Windows 10.0 Build 19044; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: CL
Comment 18 sdc.blanco 2023-02-26 01:56:14 UTC
Some points of clarification:  

1. The attachment 156451 [details] corresponds to the description in the OP. That is, a Chapter (document) field type is inserted. (It is not a cross-reference as discussed in comment 2, comment 6, and comment 7).

2. There is no "level" setting for a cross-reference, and cross-references would not work in this context, because they would continue to refer to the same heading.

3. In part, the OP seems to reflect a misunderstanding of the function of the "level" attribute for the Chapter field type - by assuming (reasonably, but incorrectly) that the "level" specifies the outline level of the "Chapter name" to be displayed. (this is a documentation problem, which is being addressed, e.g., bug 153560 comment 9).

4. The test case in attachment 156451 [details] is focused on the first page. There may be a bug in the actual behavior of "Chapter" field types when inserted in the Header on the first page of a document (see bug 93904, comment 6), which could obscure understanding/diagnosis of the problem, but even if that bug was addressed, it would not address the main issue in the OP.

5. The main (and genuine) problem of the OP is raised in comment 5

     When a new level 2 chapname appears in middle of page, 
     it only start to show on the FOLLOWING page.

but there is a critical ambiguity here. What if two new headings with outline level 2 appear on the same page, which one should be shown in the header?
(this point is raised in comment 10)

6.  comment 12 has some great examples (plausible use cases), which I believe are impossible to achieve with the Chapter field type for the following two reasons.

Two main showstoppers: 

a. It is not possible to specify very precisely (except for outline level 1) what outline level to use for the field.

b. The Header does not "read forward" to pick up the header on the page where it appears.  (This is also the complaint of the OP).

[side note:  The field in the Header does "read forward" if a new page starts with a heading, whose outline level is within the "level" range specified for the field.]

Maybe those two problems (a) and (b) should be separated into two different tickets, if they do not exist already.
Comment 19 sdc.blanco 2023-02-26 02:20:21 UTC
(In reply to jeanmarczambon from comment #12)
> A typical case is a document which first page starts with different heading
> levels (see attachment):
Or this related case (bug 93904, comment 3), where both outline level 1 and outline level 2 headings are desired in the header for all pages.