Set footer text as text of first Heading 1

I need to set the footer text of a Writer template as the text of the first Heading 1.

I added Insert -> Field -> More Fields -> Cross-references -> Headings -> Referenced text to the footer. This correctly inserted the text of the first heading into the footer as expected.

However, this is a template. I need the field to update when the template is used to create a document. As is stands, when I edit the first Heading 1 I get the following text in the footer: Error: Reference source not found.

How can I configure the footer text field to update dynamically as the first Heading 1 changes?

LibreOffice Writer 7.4 on Kubuntu 20.04.

You can use Fields - More fields - Chapter - Chapter name (from Document tab) instead, that will automatically update when you edit the heading. But Cross-reference - Headings - Referenced text works for me as well. Even from a template.

2 Likes

There is a semantic difference between both.

  • Chapter Name is a generic “dynamic” which references the current outline state to extract the data for the level you requested
    Therefore it will work under all circumstances
  • Cross-references on the contrary reference a specific “static” occurrence of some marked text
    They are associated with a given text at a precise location. Replace this text, the occurrence is lost and you get the error. There are two consequences:
    • when chapter changes due to a new Heading 1 paragraph, the cross-reference itself remains the same, i.e. you have chapter 1 heading in chapter 2
    • depending on how you change your Heading 1, you may or may not have the update in the footer. Usually, it doesn’t work.
1 Like

I am pretty sure that is what placeholders are for.

  1. Set the paragraph style to Heading 1 (Ctrl+1) at your desired position
  2. Click Insert > Field > More Fields (Ctrl+F2) and select tab Functions
  3. Click on Placeholder, make sure Text is selected, and enter your hint text in the field Placeholder, e.g. Heading 1 goes here and click Insert button
  4. Click in your footer and in the still open field dialogue select the Cross-references tab. Under Type select Headings, under Refer using: select Referenced Text, finally under Selection select the heading with your placeholder text, Heading 1 goes here and click Insert button, then Close.

Sample
Heading1ReferencedInFooterTemplate.ott (11.2 KB)

1 Like

There is no need of placeholders provided the “correct” field is used in the footer.
Insert>Field>More Fields, Document tab
Type Chapter, Format per taste, Level the level in which you list your chapter, usually 1.
It works even if there is no Heading 1 in the text/template (in which case it is void).

1 Like

There is some use for a placeholder if you delete all text in the template, except the footers.

No: if you use chose Chapter field in Document, it will capture any current Heading 1 (or level you chose), present or not. There is no need for a “skeleton” Heading 1 in text. Think also that the placeholder can be deleted.

Placeholders in template are most useful when the template is made available to many users who may not practice frequently this template. Here, placeholders are clues to usage but they should be replaced by real text. Placeholders are a way of documenting a template such that the clue disappears “naturally” when it is replaced by the intended data.

2 Likes