Update styles in a template based on a derived file?

I created a template. I then created three documents (ODT1, ODT2, ODT3) based on that template.

Now I’ve decided to modify a few styles in ODT1. Is it possible to update the template so that the changes in the styles in ODT1 will be taken over in the template?

(Since I have not found a way to update the template, I manually updated the template. I then opened ODT2 and ODT3 and expected LibreOffice to tell me that the template has changed so that I can click “Yes” to change the styles, but there was no message, so the styles in ODT2 and ODT3 are not updated. Neither does “Load Styles from Template” work. What am I doing wrong?)

1 Like

From the help:

Chapter 8, Introduction to Styles

Chapter 9, Working with Styles

It is likely that your templates are not correctly “integrated” into LO (specifically Writer here).

There are two ways to use templates.

  • quick’n’dirty method
    You double-click on an .ott file. This creates a fresh .odt with initial content (text and styles) coming from the .ott but Writer immediately forgets the origin. The document is not linked to the template and any modification will not be forwarded to the document.

  • template known by Writer
    This requires a preparatory phase where the template is registered with Writer (in fact LO in general because all templates are managed the same). I recommend you store the “integrated” templates in a dedicated user directory to facilitate maintenance.

    • create a Templates directory in your home folder (e.g. /home/<user>/Templates under Linux). If you have many templates, you can spread them into subdirectories.
    • register this directory with Tools>Options, LibreOffice>Paths, Templates item. Note you can add several subdirectories if needed.
    • design your template and save it as .ott among your documents (File>Save as)
    • make Writer aware of the template with File>Templates>Manage Templates
      • click on the Import command
      • select a category (My Templates is a good choice but you can create any category if you prefer) and OK
      • navigate to your saved template
        This will copy the template into your Templates directory. You must now decide if the reference template is either the one among your documents or the one in Templates. The latter case is simpler and you can delete the original one in your documents.
    • to use your template for a new document, File>New>Templates and select the desired template
      Doing so records a link to the template in the document. Any change will trigger the question about updating styles.
    • to edit a template, File>Templates>Edit Template

Only the second method keeps a link between a document and its template.

4 Likes

Thank you, @ajlittoz, for your detailed explanation. I wasn’t aware that using the quick’n’dirty method won’t update a file if the template is changed, but this makes sense, of course.

However, it turns out the template I’m using is indeed saved at the correct location (I had not used the Import command, but Manage Templates reveals that the path to the template folder containing the OTT file is recognised by LO as the one where My Templates are stored).

I’ve now made a conspicuous change to the Text Body paragraph style (I set the font colour to red), saved the template, and then opened ODT1, which is based on (= was created using) the template I’ve just changed. Mysteriously, in ODT1, the Text Body paragraph style remains unchanged (I had expected the font colour to turn red).

In the file ODT1:

  • File > Properties … > General, Template lists the correct (and unique) template name, so I assume LO is linking the ODT1 file with the correct template.
  • Styles: Styles actions > Load Styles from Template, select the template name, tick Paragraph and Character, OK. No change in the Text Body paragraph style.

What else can I do?

Remember that benefiting from advanced document management features (notably automatic style update from templates) requires a strict formatting discipline. In other words, you must use styles exclusively and avoid at all cost direct formatting (= manually applied attributes).

There are also also requirements. I suppose you didn’t get the question about style update. This can happen if you moved your document relative to the template location (or symmetrically, the template was moved). Inside the document, template location is stored as a relative path. Therefore, any change will make the template unreachable.

With “Load Styles from Template”, don’t forget to tick the override checkbox otherwise Writer ignores identically named styles so that it does not erase intentional style customisations.

Also check that no direct formatting is in effect. You can tell with the style inspector (bottom icon in the side pane. Due to inheritance (similar to cascading in CSS), all parameters have a “transparent” state which cannot be shown in the UI (a parameter always shows a “value”). So, if you ever touched any setting, it is no longer in “transparent” state, even if it looks similar to parent value, and will override inherited changes (and will be considered intentional change with regard to load styles from template).

2 Likes

Ticking “Overwrite” in Load Style from Template resolved the issue at last. Thank you!

I’ve checked to make sure there is no direct formatting involved, in neither file (OTT and ODT), and there is not.

Yes, since I first created the ODT file based on the OTT file I have moved the ODT file to a different location. When resuming work on a file I usually make a copy of it, rename it (= add a suffix to the file name) and move it to a new folder, but I’ve now seen that I can relink the ODT to the OTT via Manage Templates.

Strange! As far as I know, Manage Templates does not allow to link to or change a template. You may have moved the template to its original relative location with re-registering the modified template.

A very useful extension when working with templates is the TemplateChanger extension (unfortunately, I can’t link to the download server which seems to have some temporary problems just now). This extension allows you to assign any template to an existing document. Thus you can fix the relative location after moving the document by reassigning the template.

1 Like

Interesting, I’m using Version: 6.4.7.2 on Linux.

  • Created a template with some custom styles, and then a document from that template.

  • Modified and saved a custom style in the template.

  • Re-opened the document and was presented with the Update Styles dialogue which I answered yes to update, the style was updated, great!

  • Then I modified the template again and saved.

  • Reopened the document and again I was presented with the Update Styles dialogue, which I answered no, then saved the document.

Now, when I re-open the document again, I do not get the Update Styles dialogue, I suppose it remembers that I answered no once and assumes I’ll not want to be bothered with this again?

Even when I update the template again, and reopen the document I do not get the dialogue.

I can manually load the styles from a the template, and yes overwrite must be selected, and the styles are updated.

But when I update the template again, and re-open the document, I never get the Update Styles dialogue. After once selecting No, the dialogue is not presented, in the Properties->General tab, I do see that the document is associated with the template. I can’t find any properties or preferences that would enable the check?

I can’t find any properties or preferences that would enable the check?

Because there are none.
The document originates from the document template.
But you had decided (with No) to disconnect it.

1 Like

@rowman
There must be something else with your document and/or template. I frequently answer “No” to the request when I don’t want to change a “reference document” while adjusting the template (so that I can see the differences between a new and old document), but I don’t save (because it is supposed to be a "reference doc). I always get the update question dialog on next open.

@Hrbrgr Thank you, your reply answers my query.