How to Use Word Field Codes for Dynamic Paragraph Numbering
Question details
The user needs to set up dynamic paragraph numbering using conditional IF field codes without generating empty numbered lines when the condition is false.

- Product
- Word
- Device & OS
- not provided
- Scenario
- Creating a document where specific numbered paragraphs are conditionally included or excluded based on IF field results.
- Observed behavior
- When the IF condition is false, the text is omitted but a blank numbered paragraph remains, disrupting the consecutive numbering sequence of the document.
Ensure your document is set to display formatting marks (Ctrl+Shift+8) and reveal field codes (Alt+F9) so you can accurately place the paragraph mark inside your field logic.
Enclose the Complete Paragraph and Mark within the IF Field
By placing the entire paragraph, including its final paragraph mark, inside the true condition of the IF field, the line and its numbering are completely omitted if the condition is false.
A common mistake when setting up conditional numbering is leaving the paragraph mark outside the field code. Because list numbering is tied to the paragraph mark, leaving it outside the IF statement forces the number to appear even if the text is hidden.
Press Ctrl+F9 to insert a pair of blank field brackets {}. Inside the brackets, type IF followed by your logical condition (e.g., { IF { REF Age } < 5 }).
Type quotation marks for the true result. Enter your text inside these quotes. Crucially, press the Enter key before typing the closing quotation mark so that the paragraph mark (¶) is enclosed within the quotes.
Type a pair of empty quotation marks "" at the end of the field code to tell the software to output nothing if the condition is not met.
Select the text inside the true condition quotes and apply your desired numbered paragraph style from the Home tab.
Press Alt+F9 to hide the field codes, select the entire document by pressing Ctrl+A, and press F9 to update all fields and apply the dynamic numbering correctly.

Link Numbering to Paragraph Styles
For complex documents, linking your numbered lists to specific styles is highly recommended over using direct Ribbon buttons or ListNum fields.
Manage Dynamic Numbering with WPS Writer
WPS Writer natively supports advanced field codes, including IF statements and dynamic paragraph numbering, allowing you to build complex conditional documents effortlessly with high compatibility.
- 1. Open Document: Launch WPS Writer and open your target document.
- 2. Insert Field: Go to the Insert tab, click 'Quick Parts', select 'Fields', or simply press Ctrl+F9 to create the field brackets.
- 3. Input Condition: Type your IF statement, making sure to hit the Enter key to include the paragraph mark inside the true condition's quotation marks.
- 4. Update and Test: Select the text and press F9 to update the field code and verify your sequential dynamic numbering.

Frequently Asked Questions
Why does an empty numbered list item appear when the IF condition is false?
This happens because the paragraph mark, which contains the numbering formatting, is located outside the field code. To fix it, ensure the paragraph mark is placed inside the quotation marks of the 'True' result in your IF field.
How do I view the hidden paragraph marks and field codes?
To view paragraph marks, click the 'Show/Hide' paragraph marks icon (¶) on the Home tab or press Ctrl+Shift+8. To toggle between viewing field codes and their results, press Alt+F9.
Can I use ListNum fields instead of IF fields for paragraph numbering?
While the ListNum field is great for inserting a number within a line of text, it is less reliable for conditional paragraph formatting. Using a linked numbered paragraph style inside the 'True' text of an IF field is better when you need to conditionally omit entire paragraphs.




