Numbering Fields (AUTONUM, PAGE, SEQ, and More)

Numbering Fields (AUTONUM, PAGE, SEQ, and More)

Numbering Fields (AUTONUM, PAGE, SEQ, and More)

This guide shows how to work with Word’s automatic-numbering fields in Aspose.Words FOSS for .NET, and how they differ from list-based numbering. Working with Lists covers List, ListFormat, and ListLevel – the object model behind Word’s numbered and bulleted list paragraphs. Word also has a separate family of numbering fields that compute a number at the field’s location in the text, rather than through paragraph list formatting: legal and outline auto-numbering, page and section counters, list-linked numbering, and named sequences. It models each as a Field subclass in the Aspose.Words.Fields namespace, plus the NumberStyle enum shared by list levels, footnotes and endnotes, and page numbers for choosing how a number is rendered.


Auto-Numbering Fields: AUTONUM, AUTONUMLGL, AUTONUMOUT

FieldAutoNum implements the AUTONUM field (simple sequential numbering) and exposes SeparatorCharacter. FieldAutoNumLgl implements AUTONUMLGL (legal/outline-style numbering), adding RemoveTrailingPeriod alongside its own SeparatorCharacter. FieldAutoNumOut implements AUTONUMOUT (outline numbering) and has no properties of its own beyond the base Field members described in Working with Fields.


List-Linked Numbering with FieldListNum

FieldListNum implements the LISTNUM field: ListName names the abstract numbering definition to use, and HasListName reports whether the field’s code actually supplies a name. ListLevel overrides the default list level the field numbers at, and StartingNumber sets the value the field’s numbering begins from.


Page and Section Counters: FieldPage, FieldSection, FieldSectionPages

FieldPage implements the PAGE field and FieldSectionPages implements SECTIONPAGES. Both depend on computed page layout to produce a result; as with the NUMPAGES field described in Working with Fields, layout-dependent field values are not computed in this edition because it does not include a page-layout/rendering engine, so these fields evaluate to a placeholder 0. FieldSection implements SECTION, returning the document’s current section number – it does not depend on pagination and is not affected by that limitation.


Named Sequences with FieldSeq

FieldSeq implements the SEQ field for named, independently numbered sequences (such as figures or tables): SequenceIdentifier names the sequence, and BookmarkName optionally points the field at an item elsewhere in the document instead of the field’s own location. InsertNextNumber inserts the next number in the sequence without displaying a value for the current position, and ResetNumber / ResetHeadingLevel reset the sequence’s counter to a specific number, or restart it at a specific heading level.


FieldRevNum

FieldRevNum implements the REVNUM field, and has no properties of its own beyond the base Field members.


Formatting Numbers with NumberStyle

NumberStyle is the enum used across list levels, footnote/endnote numbering, and page numbers to select how a number is rendered. Common styles include Arabic, UppercaseRoman / LowercaseRoman, UppercaseLetter / LowercaseLetter, Ordinal, and OrdinalText, alongside a large set of locale-specific styles (Kanji, Hangul, Hanja, ThaiLetter, HindiLetter1, and many others) plus Bullet, LeadingZero, None, and Custom for a caller-supplied format.


Tips and Best Practices

  • Reach for FieldListNum when a number needs to reference an existing list definition by name; use FieldAutoNum/FieldAutoNumLgl/FieldAutoNumOut for numbering that isn’t tied to a particular List.
  • Remember that FieldPage and FieldSectionPages are layout-dependent, the same way NUMPAGES is – do not rely on their Result reflecting a real computed page count in this edition.
  • Use FieldSeq.BookmarkName when a SEQ field needs to reference a number defined elsewhere in the document rather than incrementing its own counter at the field’s location.
  • Set FieldSeq.ResetHeadingLevel when a numbered sequence (such as figure numbers) should restart at each new chapter or section heading.

Common Issues

IssueCauseFix
FieldPage or FieldSectionPages always shows 0These fields depend on computed page layout, which is not part of this editionExpected behavior – use the commercial Aspose.Words for .NET if a computed page count is required
FieldListNum doesn’t use the expected list formattingListName doesn’t match an abstract numbering definition present in the documentConfirm the exact list name, or check HasListName to see whether the field’s code supplies one at all
FieldSeq numbers don’t restart where expectedResetNumber or ResetHeadingLevel was not set on the field that should restart the sequenceSet the appropriate reset property on that FieldSeq instance

FAQ

What’s the difference between list numbering and these numbering fields?

List numbering (List, ListFormat, ListLevel, covered in Working with Lists) formats whole paragraphs as list items. The fields on this page compute a number at a specific point in the text – for sequences, page/section counters, or legal-style auto-numbering – independent of paragraph list formatting.

Why does a PAGE field always evaluate to 0?

FieldPage depends on computed page layout, and this edition does not include a page-layout/rendering engine – the same reason NUMPAGES evaluates to a placeholder value.

How do I create a named, independently numbered sequence like “Figure 1”, “Figure 2”?

Use FieldSeq with a consistent SequenceIdentifier (such as "Figure") across each field instance; each one displays the next number in that sequence.

How do I control which numeral or letter style a number is rendered in?

Use the NumberStyle enum – values such as Arabic, UppercaseRoman, LowercaseLetter, and OrdinalText select the rendering style, alongside Bullet, None, and Custom for non-numeric or caller-supplied formats.


API Reference Summary

Class / EnumDescription
FieldAutoNumAUTONUM field; SeparatorCharacter
FieldAutoNumLglAUTONUMLGL field; RemoveTrailingPeriod, SeparatorCharacter
FieldAutoNumOutAUTONUMOUT field
FieldListNumLISTNUM field; ListName, HasListName, ListLevel, StartingNumber
FieldPagePAGE field (layout-dependent; evaluates to 0 in this edition)
FieldSectionSECTION field
FieldSectionPagesSECTIONPAGES field (layout-dependent; evaluates to 0 in this edition)
FieldSeqSEQ field; SequenceIdentifier, BookmarkName, InsertNextNumber, ResetNumber, ResetHeadingLevel
FieldRevNumREVNUM field
NumberStyleEnum of number rendering styles used by list levels, footnotes/endnotes, and page numbers