Use the STYLEREF \s Switch in Word DOCX Captions
Question details
Determine whether the STYLEREF \s switch can be used in DOCX files for chapter-numbered captions.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- An application generates DOCX files with captions that include heading or chapter numbers.
- Observed behavior
- Word may insert the STYLEREF \s switch when the Include chapter number caption setting is enabled.
In Word, apply a numbered heading style to a chapter heading before creating a chapter-numbered caption. Identify the Word versions your generated DOCX files need to support.
Create and test a chapter-numbered caption in Word
Use Word's caption settings to see how the switch is generated, then verify the field in the Word versions you support.
In this caption context, STYLEREF \s returns the referenced heading number without its delimiter. It is commonly treated as equivalent to combining the \n and \t switches, but its behavior is not clearly described in the main standards documentation.
Apply a heading style such as Heading 1 to a chapter title, then use Home > Multilevel List to give that heading a number.
Select the object to caption, choose References > Insert Caption, and select Numbering.
Select Include chapter number, choose the heading style used for the chapter, and select a separator. Confirm the settings and insert the caption.
Right-click the chapter-number portion of the caption and choose Toggle Field Codes. Inspect the STYLEREF field for the \s switch, then toggle the field display back.
Open the generated DOCX in each supported Word version, right-click the caption field and choose Update Field, and check that the chapter number and separator display as expected.

Edit DOCX Documents with WPS Writer
WPS Office is a free, lightweight Office alternative with a familiar interface for working with existing documents. WPS Writer supports DOCX files for easy migration, although Word-specific STYLEREF behavior should still be tested in the Word versions you support.

Frequently Asked Questions
What does STYLEREF \s do in a chapter-numbered caption?
In this context, it returns the number of the referenced heading without its delimiter. Word may insert the switch when you enable Include chapter number under References > Insert Caption > Numbering.
Is STYLEREF \s the same as using \n and \t?
The combinations are commonly treated as equivalent for retrieving the referenced heading number while suppressing delimiters. Test both forms in the Word versions your application supports before relying on them interchangeably.
How can I see the STYLEREF field in a caption?
In Word, right-click the chapter-number portion of the caption and select Toggle Field Codes. Use the same command again to return to the displayed field result.
Will the switch work in every DOCX editor?
Not necessarily. The behavior is associated with Word captions, and other editors may handle fields differently. Open and update representative files in each editor and Word version you intend to support.




