Share via

How to put Heading 1 & Heading 2 text in header?

Anonymous
2022-06-29T00:12:02+00:00

I am working on a document that has close to 100 pages and may grow. The information is organized into Chapters (Heading 1) and Sections (Heading 2).

I would like to put the text of the Headings and the name of the document in the header, like this:

   Heading1Text "/" Heading2Text              tab              DocumentName

I was able to get what seemed to be working by

  • Insert | Field | StyleRef | Heading1
  • Insert | Field | StyleRef | Heading2
  • Insert | Field | Filename.

Here's how it looks with the field codes displayed.

What is weird is that the heading text updates as I scroll through the document until I get to Chapter 2. From that point on, it never changes. It keeps showing the Chapter 1 text and the last Heading 2 text in Chapter 1.

What am I doing wrong?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Anonymous
    2022-06-29T00:30:10+00:00

    (sigh) Nevermind. I figured out what the problem is. After Chapter 1, I wanted all of the Chapters and Sections to start on a new page. So I defined 2 new styles: Heading 1 New Page & Heading 2 New Page. I had been manually setting the Page Break Before setting. I did that so I could see in the Style window what they were set to.

    I'll go back to my previous implementation. I tested it on a couple of headings and it seems to work.

    Is there a way to get the Field to use multiple styles?

    PS: Is there a way for me to mark this as solved or does that even matter?

    2 people found this answer helpful.
    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Jay Freedman 207.5K Reputation points Volunteer Moderator
    2022-06-29T01:28:42+00:00

    In the chapters that shouldn't show a Heading 2 text in the header, you could insert an empty paragraph styled as Heading 2. Then set up the header for all chapters as

    { STYLEREF "Heading 1" } { IF { STYLEREF "Heading 2" } = "" "" "/ { STYLEREF "Heading 2" }" }

    Then the header will show the whole thing with the slash and the Heading 2 text when there is a non-empty Heading 2, but only the Heading 1 text when the paragraph is empty. You can format the size of the Heading 2 paragraph mark as 1 pt so it won't perceptibly affect the layout.

    This won't work if there are other Heading 2 paragraphs in the same chapter and you don't want to show any of them in the header. In that case, you do have to separate the chapters where changes occur with section breaks, and unlink the header in the new section from the one in the preceding section (turn off the Link to Previous button in the Header & Footer ribbon).

    1 person found this answer helpful.
    0 comments No comments
  2. Anonymous
    2022-06-29T01:20:18+00:00

    Sorry, any one StyleRef field can refer to only one style. The construction you showed is the right way to do it.

    For the PS: No one in this forum can mark their own post as the Answer. I've done it for you.

    Ok, thanks.

    0 comments No comments
  3. Jay Freedman 207.5K Reputation points Volunteer Moderator
    2022-06-29T01:13:33+00:00

    Sorry, any one StyleRef field can refer to only one style. The construction you showed is the right way to do it.

    For the PS: No one in this forum can mark their own post as the Answer. I've done it for you.

    0 comments No comments
  4. Anonymous
    2022-06-29T01:03:46+00:00

    If I want to change what's in the header so that in some chapters it shows both the Heading 1 & Heading 2 text and in others just the Heading 1 text, then I need to make a new section each time it changes, correct?

    Thanks

    0 comments No comments