Cannot Number a Chapter in a Figure/Table Caption, etc

LibreOffice: 7.4.7.2 40 (Build:2)
OS: Devuan GNU/Linux 5 (daedalus) Linux 6.11.5+bpo-amd64 x86_64

Everything seems to be going so well, right up until the end when it prat-falls into the muck.

Desire:

Create a Caption that shows (example): “Figure: 1.1”
1st digit: the Chapter
2nd digit: serial-number of image in that chapter

Standard stuff, so where am I going wrong?

Steps so far:

  1. Look up LO help
  2. Open menu:Tools | Chapter Numbering…
    (PNG of this dialog):

‘Chapter’ put in ‘Before’ + ‘:’ put in ‘After’ purely for ‘Level 1’
3. Insert Image
(there is an identical issue with ‘Insert Caption’)
4. Setup Caption so that Preview looks correct
(exactly as desire above)
(PNG on Insert Caption dialog; notice how the preview is exactly what I want (though the end result is just a Figure/Table field, no Chapter):
Screenshot_2024-11-22_00-43-23

  1. Press <OK>

What appears is “Figure: 1”
(only the ‘Figure’ field appears, no Chapter)

  1. Open menu:Insert | Field | More Fields… | Document tab | Chapter | Chapter number
  2. Press <Insert>
  3. An empty field appears
    (if Chapter number and name is chosen then only the Chapter name is inserted as a field)

As a workaround I’m using “Drawing” as a substitute for “Chapter” in the Captions, but that will surely affect the Contents listing.

What am I doing wrong?

I don’t know.


Picture.odt (36,1 KB)

LO-Version

Version: 24.8.3.2 (X86_64) / LibreOffice Community
Build ID: 48a6bac9e7e268aeb4c3483fcf825c94556d9f92
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 22631); UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded

1 Like

Tools>Heading Numbering is a tool for configuring chapter numbering (as per its name). It has effect on paragraphs styled Heading n. Note that you can choose numbering None at any level (and it is the default). Consequently, if you have not enabled numbering, chapters can’t be numbered.

The depth of chapter number used in captions is set in the Insert>Caption after pressing button Options to retrieve the current chapter number.

Inserting a field for the chapter number can be a workaround (but with less “integration”) provided a chapter heading already exists. If you have no Heading 1 paragraph, you have no chapter yet and consequently no chapter number.

Attach a sample file for better diagnostic.

  • Note that I was using “Tools | Chapter Numbering…” & not " Tools >Heading Numbering". The latter is not available.
  • I chose Number: 1, 2, 3, … and did NOT choose None.

None of those comments apply.

I just attempted adding a chapter number (field) within the Heading 1 that is enabled for numbering, and got the identical result (an empty field). Everything works fine, showing correct preview etc., right up to the point that I press <Insert>. Then an empty field.

I am using docs derived from 1_Programming-In-Python3.odt as in the Python docs as referenced in an earlier question. The document is called “2_paragraph-fixes.odt” and will be added to the rest in GitHub when I’ve completed current changes.

Wording changed some time between 7.4 and 7.6 but it is the same. Is there a reason why you don’t update to 24.8? Your kernel is quite up-to-date (6.11.5 vs. 6.11.8 here).

The referenced file is huge and probably your current document is no longer the same formatting-wise (no “automation” or field insertion in the linked file). Can you attach a reduced sample with the issue? Eventually through a private message.

It is 2.2 MB. That is more than trivial, but not huge. It has 15 Chapters and, once again, that is hardly large.

I am happy to send you a copy via PM, though I have zero knowledge at this moment as to how.

PS
You remember those Heading x decorations which were originally in a Textbox & you suggested should be in a Frame? I changed them all to Frames. Now the one for “Multiple Inheritance” (a H3 in ch8) refuses to stay in it’s Heading and has switched to the Header of Table 8.4 instead. Deleting it & recreating does not work.

PPS

24.8 is available in Devuan via Backports. However, there are large changes in the Repository setup re: 7.4.7 which mean that it is NOT a drop-in replacement. I’m using AppImages for latest + early v7 instead with repository-7.4.7 as the default. I cannot find a compelling reason to switch to 24.8.

I’ve reduced it down to the 1st 8 chapters. Lets see if askLibO will allow a 1.5 MB file upload (it refused the 2.3 MB original in a PM to you).

Nope.

Sorry, that file is too big (maximum size is 4 MB).

askLibO is lying through it’s teeth. Sorry.

Deleting the last 7 chapters’ text was quick, but then having to trawl through & delete every Table & Image in those 7 chapters that was left behind was a pain. I’ll eventually get the 2_paragraph-fixes.odt up to github. It is showing every sign of large-scale corruption, yet again.

Hi PKG. Thanks for being honest.

I’ve finally worked out for myself the actual mistake that I made. A stupidly simple mistake that, it seems, no-one else is aware of (and which is not documented). It goes like this:

My Mistake:

My order of work was:

  1. Create a document full of ordered Heading 1 (H1), H2, H3 & H4 Chapters
    (4-level Chapter headers)
  2. Use menu:Tools | Chapter Numbering… (v7.4.7) to create Chapter numbers
    (menu:Tools | Header Numbering… (v24.8))

That will NEVER work. The only way that will work is as follows:

Fix It as Follows:

  1. Use menu:Tools | Chapter/Header Numbering… to create Chapter numbers
  2. Create a Heading 1 paragraph
    (the number will get auto-added in the Heading position that you specify + Chapter numbers become auto-available)
  3. (optional) Create a Character Style to specify in the Chapter/Header Number dialog
    (a 1pt character with the same colour as the paragraph will cause the Heading number to disappear in the H1 if you do not want it)

Ignore everything that is said about Direct Formatting in the replies to this topic. None of it applies. Making use of Styles is strongly advised for large documents, but not required, & will cause zero harm unless you use the Default Paragraph Style throughout a 600 page document, in which case it will attempt to destroy your physical computer (unfortunately not an exaggeration).

Examples:

v7.4.7 example ODT
v24.8 example ODT

The origin of the problem is in the clumsy (no offence intended) imitation of chapter start layout of the original book.

Presently, your chapter headings are styled Heading 1 with a LOT of direct formatting to force resemblance to the goal. Tools>Heading Numbering requests numbering (with Chapter prefix and ; suffix). Direct formatting then removes the number because you want the number separated from the heading at top of page. You send this number into the header (where it does not make sense because a header is supposed to contain only “static” reference-able data not participating in text flow). You also want a kind of chapter TOC aside the number. Once again you send this mini-TOC in the header as a drawing object (this is less harmful structurally speaking because it is static data) but you should avoid drawing objects as much as possible, all the more when they are related to text.

What happens is your DF (=direct formatting) cancels the existence of chapter number. Therefore, whenever you reference level-1 heading number, you get void value, simply because the number does not exist.

You attempted to compensate by using a number range (Drawing) which you dedicated to chapter numbering. Unfortunately, a number range is not the same as list style (which links together 10 number ranges with hierarchical reset) and this creates more problems later than it solves.

In addition, you need one page style per chapter in order to insert all your chapter-specific manual data. If you could cross-reference through fields, a single first-page chapter page style would do the job for all your chapters.

Proposed Fix

  1. Reintroduce the number into the heading
    Use Heading 1 as usual: let the paragraph bear its number taken from internal list style Heading Numbering.
    Separating this number from the heading itself is done in Tools>Heading Numbering, Position tab where you request a New Line after the number.

  2. Managing heading background
    You want no background below the number and a coloured background below heading text. This rules out Area in paragraph style because it applies to the whole paragraph (number + heading). Consequently, Area is reverted to None and the background will be done with Highlighting.
    Suppression of number highlighting is provided by a dedicated character style applied in Tools>Heading Numbering, Numbering Tab. I named this style Chapter Number. It defines font size, weight and variant (it is quite tricky to suppress italic coming from the paragraph style, but it is doable through a “magic stance” as can been seen in my sample) and None highlighting (has to set explicitly).

  3. Forcing highlighting from margin to margin
    Highlighing is normally done only on characters which means it stops at last character of heading. The trick is to create “fake” text up to paragraph right indent. To make things automatic and simple, a tab stop is added at right margin (17 cm, remember to adjust if you change page margins because LO allows only to create stops relative to left indent).
    Then, headings are terminated by pressing Tab. This will have no effect on TOC(s) because non-text characters are converted to spaces when TOC is collected.
    When headings are longer than one line, they wrap but we are confronted to the same issue. Generally long heading are mutually wrapped to achieve better visual effect (or to comply with grammar rules, such not separating an adjective from its noun or a preposition from its “target”). This means that author adds a manual line break. Instead, press Tab first before line break.

  4. Horizontal line below chapter number
    Sorry for this one. I tried several tricks based on border but I did not success. All I get is a stroke with the same width as the number without spacing with heading highlight.

    If this is not a stringent requirement, drop it.

  5. Chapter TOC
    This chapter TOC is a “side annotation”. The adequate tool is a frame. Inside the frame, I used cross-references to Heading 2 paragraphs.
    I did not use the chapter TOC feature because it repeats the chapter heading which, presently, can’t be suppressed. It is a shame since it would have completely automated the process.
    I created a frame style Chapter TOC anchored to right paragraph edge, slightly below top, with width limited to 8 cm, height auto-adjustable.
    I hope your chapter TOCs won’t ever require too many line, otherwise it interacts with the heading and breaks the nice presentation. This can partially be handled by modifying Chapter Number character style Borders tab to increase bottom padding. This is a global setting (no DF possible here) which must be tuned for the most demanding chapter TOC.
    Inside the frame, everything is paragraph styles Chapter TOC which is associated with list style Chapter TOC (to prefix every heading with BLACK CIRCLE). Indent is set to correctly line wrap and align below the first line text (contrary to text boxes).

    Note that there is a “Reference error” line in the chapter TOC because I referenced an Heading 2 before I deleted text to make an attachable document (below the size limit).

    My 2-cents advice is to “package” together an empty chapter heading with its side TOC frame in an AutoText entry to make it easy and user-friendly to create a new chapter heading.

  6. Chapter start page style
    Since no topic text needs to be sent in the header now, you can use the same page style (to be created) for all chapter starts. I leave this as an exercise.
    There will be no header. Adjust top margin to position chapter heading where you want it.

  7. Figure caption
    The previous corrections have re-enabled the standard behaviour of heading numbering. The chapter number has become available to number ranges and Figure displays again the chapter number without the need for fake Drawing number range.
    I checked by adding a second caption to Fig 1.1 before realising that the Figure field already contained the expected chapter number. This second caption is of course number 1.2.

Other severe pending problems

I suspect these problems come from the initial acquisition process of the text. Did you use an OCR program (perhaps applied to PDF) which would have introduced DOCX or “alien” formatting primitives?

Figures

I deleted text at end of privately sent document and saw that the number of pages did not decrease. This is a symptom for badly anchored frames.

Effectively, all your frames are anchored To page which means they remain attach to a designated physical page, causing many intermediate undeletable pages. I had to delete them manually.

You should design an adequate frame style for them. It is obvious they share the same properties and a single style can do the job. Take special care to anchor this frame style To paragraph.

I remind you that anchor and position are independent settings. A paragraph-anchored frame can be position anywhere in the page. So choose sensible parameters. Pay attention to Allow overlap. Untick it so that multiple conflicting frames in the same page can be automatically repositioned by Writer. I don’t understand why developers chose to tick it by default, which leads to numerous user complaints about positioning.

Above all, refrain from changing frame position manually with the mouse. Frames are extremely highly (sorry for pleonasm but I can’t emphasise enough the risk here) sensitive to DF. And this DF form is very difficult to remove (making frame styles rejected by most users).

Tables

After understanding the problem with frames, I faced another issue with **tables**. The tables behaved exactly like page-anchored frames and, in addition could not be deleted with Del.

Apparently, they are page anchored though there is no UI for it nor parameters in properties. The only way to get rid of them is right-click + Delete>Table. I did that for a few of them but was too lazy for the rest.

Sample

Here is a reduced sample with my “fixes”: 2_paragraph-ajl.odt (312.5 KB)

Study the new styles.

UPDATE 2024-11-24

Tables

Your tables are contained in a frame with the exact size of the table. And since these frames are anchored to page, they are the culprit for the “persistent unmovable tables”.

There is no point jailing the tables in frames unless you want some text aside the table. And in this case, the frame will likely be anchored to this paragraph.

I suppose that the frames were used to reduce table width (so that they don’t extend from margin to margin). This can be done more comfortably through table properties (and decreasing thus the number of frames will make Writer more reactive).

A caption can still be created for the table. Indeed, it is less strongly attached to the table (because it is no longer in the table frame) but you can force the table to Keep with next paragraph to make table+caption an atomic block.

The only drawback I see is the impossibility to position the table anywhere in the page. It is now part of the text flow, meaning it can cause white space at bottom of page before the table at next page. I seem to remember having found settings which allow to have the paragraph on a page and the frame on the next one. The combination of settings is tricky but stable. The context is also important. It works only if the paragraph is the last on the page. We may talk about this later in a separate question or privately.

Thanks for taking the time to produce a test ODT.

I do see that that your duplicate Heading 1 has proper Chapter Numbering but am having a hard time understanding exactly what Direct formatting (sorry to swear there) has removed it from my original Heading 1.

I will return to this much later, since I have some other stuff that I need to get completed first.

No.

Look at the GitHub Python3docs README & you will see this phrase:

Note:

The ProgrammingInPython3 PDF is chock-a-block with internal + external links, but none of those links are active. As I had a little time, I resolved to add those links into the PDF.

‘ProgrammingInPython3.txt’ obtained from ‘0_ProgrammingInPython3.pdf’ using pdftotext

Thus, plain-text throughout, no ‘formatting primitives’ of any kind.

Your statements are nonsense (sorry).
.
Attached is Chapter_02.odt (below). That (oh horror!) contains all the direct formatting that you state is responsible for the problem. It also has a Chapter Number in existence. A Field containing that Chapter number is deployed at the top of the Chapter, and also within both Figures & Tables.
.
You need to get off this Hobby Horse of yours. It is perverting your good judgement.
.
It is the order in which Chapter/Header Numbering… + Heading 1 are deployed that determines whether Chapter number fields are available. If Header paragraphs are setup first (as I originally did) and then the Chapter/Header Numbering… is setup, that will be ineffective. Do it in the reverse order & bingo!, it works. The test ODT that you sent me was the clue that led to this solution, so thanks again for that.
.
The one remaining problem is that Chapter/Header Numbering… will auto-add a number to the Header 1 paragraphs. That is a profoundly stupid design decision IMO. I’ve hidden it by specifying a Character Style that has a 2pt font in the same colour as the background for the Header.
.
I’m attempting to get around all the bugs that destroy a long book by using a Master Document setup. That complicates intra-document links a lot (it requires excessive use of bookmarks) but at least I will have a book where various sub-sections do not gain legs & begin to walk around of their own volition.
.
Here is Chapter 2; lots of editing is still required on it, but it amply demonstrates my statements at top:

Example:

chapter_02.odt (314.1 KB)