[Tutorial] Adding a Variable SubHeader to a Header

Forum rules
No question in this section please
For any question related to a topic, create a new thread in the relevant section.
Post Reply
BobSongs
Posts: 3
Joined: Sat Jul 10, 2010 4:21 am

[Tutorial] Adding a Variable SubHeader to a Header

Post by BobSongs »

(I'm using OpenOffice 3.1.1 in Ubuntu Linux 9.10, however, this works fine under all recent versions of OpenOffice/NeoOffice.)

The idea here is quite simple. When writing a document I might want a main title to appear in a header throughout the document like this:

Book Title
Chapter Title

It's easy to get the "Book Title" in and have it remain constant in the header. But how about that Chapter Title?

The following is a brief tutorial on how to do just that.

Note: feel free to apply formatting to the Header area. I just left it raw and unadorned for the sake of the tutorial.

---------------------------------------

In OpenOffice Writer, create a header like this:

From the menus:
  • Insert -> Header -> Default
My Header area is now created.

Inside the Header area, I will write the text that I want to appear on each page: Book Title.

For my purposes, I'll hit Enter to provide space under "Book Title".

NOTE: There's no need to include text that remains the same throughout the document.

So far:
Img1.png
The second line in our header will be "dynamic", meaning, it changes from section to section (in this case, it's the Chapter Title).


Creating our "SubHeader" (Chapter Title)
Scroll through your document until you find the first heading you wish to use as your Sub-Header. Click to the left of the text as illustrated below.
Img2.png
important
You might notice that your SubHeader (the Chapter Title) may not show up on the first page. (I'll explain that more fully in an additional post.) That is because the code we are about to create isn't the very first thing on the page. To have a Subheader appear on the very first page, make sure the code (that we'll look at below) is the first thing on the page.

AGAIN: The way I've placed my cursor, the SUB-HEADING (Chapter Title) will NOT appear on the first page. This is DELIBERATE.


Adding our Sub-Heading (Chapter Title)
From the menus:
  • Insert -> Fields -> Other (or, from the keyboard, press Ctrl+F2)
When the "Fields" box appears:
  1. click the Variables tab
  2. click Set variable
  3. click Text
  4. In the Name field, I will type SubHeading (no spaces)
  5. In the Value field, type what will appear as your sub-title (that is, our Chapter Title for this tutorial). In this case I'll use The Quick Brown Fox.
  6. Click the [x] Invisible check-box.
  7. Then click the Insert button.
  8. Then click the Close button.
Img3.png
When we return to the document, you MAY or MAY NOT see what was added.


Let's expose the new code!
From the menus:
  • View -> Field Names (or, from the keyboard, press Ctrl+F9)
This hides/shows our newly added "Fields". Exposing your fields makes locating them a snap.


Adding our Sub-Title to the header
Click in the Header and place the cursor where you want the sub-header to be:
Img4.png
Adding the sub-header will resemble creating it. From the menus:
  • Insert -> Fields -> Other (or, from the keyboard, press Ctrl+F2)
Your "Variables" tab should still be selected.

When the "Fields" box appears:
  1. click the Variables tab (should be selected)
  2. click Show variable
  3. click Insert.
  4. click Close.
AGAIN: Your sub-title will only appear on the FOLLOWING PAGE if the "Variable" was not placed at the very beginning of the text (again: NOT in the header itself).


Changing the Sub-Heading mid-document
Now we come to the point where we change the text that appears as our Sub-Heading. In my document I want to make this change on page 3, and I want to change the sub-heading from "The Quick Brown Fox" to "Concerning Jumping".

My heading within the document happens to be at the top of Page 3. And you can clearly see the sub-heading "The Quick Brown Fox". Now I will change it to the new sub-heading.
Img5.png
From the menus:
  • Insert -> Fields -> Other (or, from the keyboard, press Ctrl+F2)
When the "Fields" box appears:
  1. click the Variable tab (if not already selected)
  2. click Set variable under "Type"
  3. click SubHeading under "Selection"
  4. click Text under "Format"
  5. in the "Value" field, add the new sub-heading (Chapter Title -- in my case, "concerning jumping").
  6. click [x] Invisible
  7. click Insert.
  8. click Close.
Rinse and repeat.


Changing a Sub-Heading (Chapter Title) that's already created
:crazy: Well, there you go. You've gone and done it. You created a subheading and now you don't like what it's called. How do we go about changing it?

Simple:
  1. Press Ctrl + F9 until the code is revealed in the body of the text.
  2. Double-click the code.
  3. The "Edit Fields: Variables" box will appear.
  4. Make your changes there in the Values field.
  5. Click OK to complete the change.
Image
Last edited by BobSongs on Wed Jul 21, 2010 10:51 pm, edited 9 times in total.
OpenOffice 3.2.1 on Ubuntu 9.10 - the Karmic Koala; OpenOffice 3.2.1 on Windows XP Home SP3 (Hah! My copy of XP is legit!); NeoOffice on MacOS 10.4
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Tutorial] Adding a Variable SubHeader to a Header

Post by Hagar Delest »

Why make the variable invisible? You can make the heading a variable itself, then, no need to duplicate the work by changing first the heading and then the variable.

Note that if you use the Outline Numbering feature, there is no need to set variable, headings can be inserted as fields in the headers/footers. The only drawback with the Outline Numbering feature is that it looks at the first paragraph heading level. If there is text (even empty paragraph) before the first heading, nothing is shown in the header then.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
BobSongs
Posts: 3
Joined: Sat Jul 10, 2010 4:21 am

Re: [Tutorial] Adding a Variable SubHeader to a Header

Post by BobSongs »

Hagar de l'Est wrote:<snip>Why make the variable invisible?</snip>
Hagar has a point. The variable does not need to be invisible, and can be used as the Chapter Title, as detailed below.

If the format of the chapter name is exactly what you desire to be in the header, then use this procedure to create chapter names:
  1. Press Ctrl+F2
  2. The Fields box appears
  3. Enter the chapter title in the Value field (example: "Concerning Lazy Dogs")
  4. Click Insert
  5. Click Close
This way your field is also your chapter name in the document.

If, however, your document's chapter names differ from what you want as a sub-heading then use the method in the tutorial.

An example would be when you apply an artistic style to the chapter title you don't want reflected in the header.

In the document, the Chapter Title looks like either one of these:
  • concerning lazy dogs or (Heaven forbid) CONCERNING LAZY DOGS
and in the header, you want the Chapter Title with leading capitals only:
  • Concerning Lazy Dogs
Remember: standard text formatting can be applied to the code you insert into the text just as you would with any other text.
OpenOffice 3.2.1 on Ubuntu 9.10 - the Karmic Koala; OpenOffice 3.2.1 on Windows XP Home SP3 (Hah! My copy of XP is legit!); NeoOffice on MacOS 10.4
Post Reply