Add chapter numbering into a template

Chapter numbers are assigned to heading. Selective chapter numbering can be done using menu → Tools → chapter numbering … see https://ask.libreoffice.org/t/style-list-heading-n-and-level/71586/2 This work fine.
But these chapter numbers are not assigned to the template but to the document.

I would like to embed to save my configuration in a template .ott. This is possible. But using a .odt document, with this template the chapter numbering is lost. I have to assign it again in the .odt document.

So I am missing a single point of references. In a master document . odm I can add this, but I also have to add this in each detail document, for the same effect. Even if both documents use the same template.

The settings in tools -chapter numbering can be saved. In https://help.libreoffice.org/7.2/en-US/text/swriter/01/06060000.html?&DbPAR=WRITER&System=UNIX it is described as a special document, which seems separately from the style.

In this structure I miss something. I understand direct formatting, stored in the document. It is fast, but unusable for large documents. I understand templates more and more. But chapter numbering seems not to be part of a template.

I would like to understand the structure of storage of chapter numbering. So I can use it effectively, designed in the template and reuse it.
To resume my question (with information of some comments):

  • Can something be DF (Direct Formatted) in the template, in .ott, without being used in the .odt file?
  • How to enforce chapter numbering in a template. Double click an .ott with correct chapter numbering, is used to create a new untitled.odt document “the strong way” . But this total new document, without making any modifications, the chapter numbering as defined in the .ott is lost. What happened, and how can this be solved?

My favourtite document regarding structured documents: https://www.openoffice-uni.org/

LibreOffice is, special on details, not identical to OpenOffice. Beside that, the last actual English version is of the year 2015.

Settings from a template wouldn’t transfer to a document only if you overrode Tools>Chapter Numbering in the document itself.
Also, automatic style update from the template occurs only if the document was “correctly” template, i.e. is known by Writer to derive from a template.
You have two ways to create a template-based document:

  • the weak way: double-click on a template file
    This creates a new document from the template but the dependence is not kept.
  • the strong way: File>New>Templates
    This implies that the template was stored in a specific template directory with File>Templates>Save as Template. Writer is then aware of your user template. When you re-open a document after template update, you’ll be asked if new style definitions should be forwarded to the document.

@ajlittoz When I use the strong way, the template is indeed stored in the document property Menu → File → Properties, In tab “General” the field template has the name of my template. This work fine for new documents.
For existing documents I prefer to use the extension “Template changer” you advised in an other thread. This seems to work well. And the Menu → File → Properties I can see the template is assigned. It seems to me it is identical. Is it also identical?

I might overrode Tools>Chapter Numbering in the document itself, it is hard for me to recall. If so, is this visible somewhere, and can it be undone?

I feel templates are really powerful, and I do like the idea and structure. I like the idea of single point of reference a template give. The result will be predictable. With the option to override, the single point of reference is lost. And without a proper way to detect this, or remove this with a kind of CTRL-M it is hard to solve. With a hard to detect override, the predictability is reduced.

Yes, TemplateChanger is strictly equivalent to the “strong” way. It allows to fix the case when you didn’t use the “strong” way.
The overriding situation arises because you have two files: the template and the document. It is similar to direct formatting overriding where the styles and DF live in different layers.
However, considering the progression in the discussion, I think something else is occurring. Can you attach your template and a sample file with the mishap? If it is not possible to recreate the problem, use your present document, reducing it to 1-2 pages and replacing personal/confidential data with anonymous text.

Both suites produce the same ODF documents with slightly different user interfaces. The tutorial teaches all the concepts around styles and indices correctly.

I thought so, but it is not identical. When double click on a template, a .ott file, an new document, a .odt file is created with the content (in text) of the template.

First I created a empty template, with all styles, but without text. Because of this functionality. That does work, but it is hard to see, which style has which effect.

Now I do it different. I create a template, a .ott file, with text, with examples of the effect of the styles. When I use the TemplateChanger, the template styles are used, but the text is not. Which is also my desire. This I do like, because I have a visual feedback of the specific styles I use.

In this template, so a .ott file, I do have chapter numbers correctly. So heading 1 and 2 are numbered, but heading 3 and higher are not, as what I wanted. But when I double click on the template file, a new document, a .odt file is created. But within this .odt file, heading 3 and higher are also numbered. Can something be DF (Direct Formatted) in the template, without being used in the .odt file?

That’s very roundabout. You can build a template with some text in it that you are sure you will use in all documents based on that template. Start with a title page, with dummy text for the title, and following pages without headers and footers, include a TOC, include one chapter title with a dummy text, include some section headings with also dummy text, etc. Then save as template.

That could also be. That would be attractive for repeating the same style of document, over and over again. But when using as master document with subdocument it will be not possible anymore. Because the TOC, the Titel are multiplied.

I go for previous suggestion:

You don’t make changes in the sub documents, you just modify the styles in the master document with the same names as those in the sub documents.

I tested that and found that the Chapter Numbering settings made in the template file are kept in a document based on that template. Maybe you did some direct formatting that overrode those settings?

You definitely don’t have to modify settings in a sub document. That is in fact the entire point of master documents. That you can have several documents, articles intended for a magazine or as chapters in a book, with a general formatting that gets overridden in a master document where those documents are included. In one master document you make the settings fit for publication as a magazine, in another you make it fit for publication in book form. You don’t make changes in the sub documents, you just modify the styles in the master document with the same names as those in the sub documents. That is crucial: that all styles used in the sub documents (and that may be defined differently in each) are also defined in the master document.

@anon87010807 That is indeed what is my desire. One template used for all, without using Direct Formatting.

With further testing I found the Chapter numbering was saved separately from the template. I did save the chapternumbering, within the dialogbox of chapternumbering. When saving, and reopening the .ott chapternumbering configuration is lost again. But I could open it again with Menu → Tools → Chaptere numbering … and select the used name. After this action the chapternumbering is correct again.

So it seems that the chapternumbering is saved separately in LO 7.2.3.2, and not linked to the template. It seems, that, in Ubuntu, /Home/.config/libreoffice/4/user/config/chapter.cfg is used. Seemed, because the name with the chapter numbering is stored, is mentioned in this file. Seemed, changing the chapter numbering, does not change datetime stamp of that file.

I did not found a solution, but a workarround. Open the chapternumbering file each time a document is opened. Quite awkward, but it works. I am open for a real solution.
With this info there is no solution, but a workarround.

Quite awkward because I never experienced the issue. I’m very curious to the cause. So, I insist once again you provide your template and an anonymous document for me to experiment.

I could isolate a small .ott and ,odt file where this situation still exist. But due to personal reasons, I am not able to upload it now. This has nothing to do with LO. When I am able to upload, I will do so. @ajlittoz thanks for your interest. And I hope you will have the patience to wait.

@ajlittoz I uploaded the .ott and the associated .odt file where this happend:
Scientific_book_test4.ott (15.0 KB)
Scietific_book_test4.odt (15.0 KB)

Open the ott for editing. Check the Heading 1 paragraph style, Text flow tab. There you have Insert page break before with page style Right page **with footer**. But the Format - Paragraph dialog box for that paragraph shows that you have that formatted as Insert page break before with page style Right page. So that one overrides the settings in your paragraph style.
The settings in Tools - Chapter Numbering seem to have been properly imported in the odt.

Works correctly for me. When I change the template chapter numbering and File>Reload the document, it is updated as per the template.

To get your levels 3+ unnumbered, don’t forget to set Number: to None in Tools>Chapter Numbering. It is not set so in the template, leading to numbered levels.

@ajlittoz This seems to be the difference. I set Tools → Chapter numbering At show sublevels: 0 Which did not work. You set the number: None, this did work indeed.
It is, however, confusing sublevels: 0 should work also.

But, unfortunately for me, not with Menu → Styles → Update selected style, nor with Menu → Styles → Load style with template. But it did work wit the template changer Menu → Templates → Change current template (current document).

It does, work, that is the main thing.

@anon87010807 That is correct. On heading 2 I did something equal. Insert page with style: Left page with footer and header. On Heading 1 it did work, and Heading 2 it did not. So I enforced the desired style with a page break.
Could you detect why that it did not work for Heading 2?