Custom header for each chapter

What I have:
Chapter name (Heading 1): The First Chapter

What I want to achieve:
The chapter name in Spanish (ex: El primer capitulo) in the header.
The Spanish chapter name appears in the header but not in the document.

I’m thinking about creating a page style for each chapter then manually type in the header, but it’s too cumbersome.

Is there any elegant solution to this? Thank you.

Thank you @mikekaganski and @ajlittoz for taking your time to help me.

Actually, what I want is like @mikekaganski described: arbitrary, free-form text in headers/footers, related to “chapters” but not the same as their names. My document is in Vietnamese, “The First Chapter” is just a simplified example.

I’m fairly new to Libreoffice, I only knew how to insert predefined fields like chapter name, page number. I’m not familiar with Set Variable field or Frame.

As far as I understand, I can hide some texts in the document and use it in the header, am I right? Can you show me how to do it? Much appreciated!

I realize that my proposal may be no less cumbersome.

When I needed a similar thing (arbitrary, free-form text in headers/footers, related to “chapters” but not the same as their names), I used a frame with Set Variable field. The frame had a “do not print” property; I placed it somewhere near the heading of the chapter (usually at left or right margin), and used that field value in the header/footer. (Note that in headers, it will only be available starting from the second page of the chapter…) And I copied the frame into each chapter. A mess :slight_smile:

But your question’s wording gives room for some uncertainty. “The First Chapter” and “El primer capitulo” both include spelled-out numbers - so are the chapter names really like that? If so, then maybe just use normal numbering, and only define respective numbering style (available since version 6.1)? Together with text/field language, they would provide you with English or Spanish spell out in respective places.

Hi @mikekaganski, I tried your solution but if I set the variable to a string value, it prints as 0 (zero) even if its format is forced to string. Is there a trick I missed to assign a string to a variable? Presently, I must use a “user field” for string value.

However, provided the frame is anchored to the Heading 1 paragraph (which configuration is changed for “page break before” in Text Flow), the (numeric) value is available even in the header of the first page. Probably, this is a by-product of the algorithm to capture chapter number.

СПАСИБО @mikekaganski , it’s all my fault. I didn’t type beforehand the variable and since it can’t be changed afterwards …

There are various ways to achieve your goal but as @mikekaganski pointed out, your specification is not rigorous.

You must play with the fact that character styles are not captured by the field engine.

As usual, a header is built with field insertions to display the current chapter heading and its numbering. El primer capitulo may either be the chapter name itself or the “decorated” chapter number corresponding to “1” (with El and capitulo being strings added to the formatted number).

In the header you can separately insert the chapter name and its number.

The chapter name can contain visible and invisible words if you apply a character style with attribute Hidden (Font Effects tab) over them. The hidden words won’t show up in the chapter heading not in the TOC but are present in the chapter name field and will be displayed in the header.

The case of the number is a bit more difficult because you can’t apply manually a character style (because you can’t select the number by itself). In Tools>Chapter Numbering, you can define a Character style to be applied to the number but the hidden attribute is ineffective here. Any other attribute is respected, but this one no. This means the number will always be visible in chapter heading, page header and TOC.

Depending on your goal, you may try various combinations of these possibilities.