How to Include Heading Numbers in a Word STYLEREF Header Field
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.

- 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.
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.
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.
Double-click the top margin of your document to open the Header & Footer editing area.
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.
Click immediately outside the closing brace of the first field and press the Spacebar to add a gap between the number and the text.
Press 'Ctrl + F9' again to insert a second set of field braces. Type 'STYLEREF 1' inside these braces to pull the heading text.
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.

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. Open the Document: Launch WPS Writer and open your document. Double-click the header area to activate it.
- 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. 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. Update Fields: Right-click the inserted fields and select 'Update Field' to display the accurate current heading number and title.

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'.




