Formatting Issues

How to Include Heading Numbers in a Word STYLEREF Header Field

Natalie TaylorNatalie Taylor Nov 2, 2026 868 views

Question details

The user needs to display both the auto-generated heading number and the heading text inside a document header using the STYLEREF field.

How to Include Heading Numbers in a Word STYLEREF Header Field
Product
Word
Device & OS
not provided
Scenario
Customizing document headers to dynamically reflect the current section's full heading title and outline number.
Observed behavior
By default, the STYLEREF field only displays the text of the heading style, omitting the structural heading number entirely.
Before you start

Ensure your document headings are properly formatted using built-in heading styles (e.g., Heading 1, Heading 2) and that a multi-level list numbering scheme is applied to those styles.

Solution 1Recommended

Use Two Consecutive STYLEREF Fields

To display both the heading number and the heading text, you must insert two separate STYLEREF fields side-by-side, using a specific switch for the number.

A single STYLEREF field cannot extract both the text and the number simultaneously. You need one field configured to pull the numbering and a second field to pull the actual text. Referencing the heading level by its number (e.g., '1' or '2') instead of its name (e.g., 'Heading 1') ensures the fields continue to work if the document is opened in a version of Word with a different display language.

1
Access the Header

Double-click the top margin of your document to open the Header & Footer editing area.

2
Insert the Number Field

Press 'Ctrl + F9' to insert a pair of field braces. Inside the braces, type 'STYLEREF 1 \n' (replace '1' with your target heading level). The '\n' switch tells Word to retrieve only the paragraph number.

3
Add a Space

Click immediately outside the closing brace of the first field and press the Spacebar to add a gap between the number and the text.

4
Insert the Text Field

Press 'Ctrl + F9' again to insert a second set of field braces. Type 'STYLEREF 1' inside these braces to pull the heading text.

5
Update and Display the Result

Press 'Alt + F9' to toggle off the field codes, then select the entire header text and press 'F9' to update the fields. You should now see the complete heading number and text.

Use Two Consecutive STYLEREF Fields
Language Compatibility: Using the heading level number (e.g., 1, 2, or 3) instead of localized names like 'Heading 1' makes your document internationally compatible, preventing field errors in non-English versions of Word.
Efficient Document Formatting

Easily Manage Headers and Fields with WPS Writer

WPS Writer provides comprehensive support for standard field codes, including STYLEREF, allowing you to create professional, dynamic headers and footers with ease.

  1. 1. Open the Document: Launch WPS Writer and open your document. Double-click the header area to activate it.
  2. 2. Insert the First Field: Navigate to the 'Insert' tab, click 'Quick Parts', and select 'Field'. Choose 'StyleRef', select your heading level, and check the option to insert paragraph numbers.
  3. 3. Insert the Second Field: Add a space after the first field, open the Field dialog again, choose 'StyleRef', and insert the standard heading text.
  4. 4. Update Fields: Right-click the inserted fields and select 'Update Field' to display the accurate current heading number and title.
Fully compatible with Microsoft Word document formats (.docx).Intuitive header and footer design tools with easy-to-use interfaces.Robust support for advanced field codes, switches, and multi-level numbering.Lightweight software that runs smoothly on all major operating systems.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the STYLEREF field only show the text by default?

By default, the STYLEREF field is designed to extract only the plain text of the referenced paragraph or style. To include the auto-generated list or outline number, you must explicitly add the '\n' switch to the field code.

What does the '\n' switch do in a field code?

The '\n' switch instructs the STYLEREF field to retrieve the paragraph number (such as a multi-level list or heading number) of the referenced style instead of its textual content.

Can I reference a specific heading level instead of typing the style name?

Yes, you can use the heading level number (e.g., 1, 2, or 3) instead of typing out the full style name like 'Heading 1'. This is highly recommended as it prevents broken field references if the document is opened in a Word version with a different display language.

How do I force field codes in my header to update?

Field codes in the header generally update automatically when you switch to Print Preview or print the document. To update them manually, double-click the header, select the text, and press 'F9'.