User`s guide

Automatically Number Document Content
13-87
Automatically Number Document Content
In this section...
“Automatically Number Content Programmatically” on page 13-87
“Automatically Number Content Using Part Templates” on page 13-89
You can automatically number document content, such as chapter, section, table, and
figure headings. Append automatic numbering objects to the document where you want
numbers to appear. Each automatic number is associated with a numbering stream
that determines the value of each number in a sequence. Report generation replaces
an automatic numbering object with a number based on its position in the document
relative to other automatic numbers in the same stream. For example, the first automatic
numbering object in a stream can be replaced by 1, the second by 2, and so on. You can
use automatic numbering to create hierarchical numbering schemes such as Section 1.1.,
Section 1.2, and so on.
You can automatically number document content programmatically or by inserting
automatic numbering fields in a Word template or numbering properties in an HTML
template. For example, you can insert automatic numbering in a template for a document
part that is appended repeatedly to a report.
Automatically Number Content Programmatically
To automatically number document content programmatically, do the following at each
point in a document where you want an automatically generated number to appear.
1
Create an automatic numbering object, using the mlreportgen.dom.AutoNumber
constructor. Specify the name of the associated automatic numbering stream in the
constructor. For example, this line creates an automatic number belonging to the
stream named chapter.
chapterNumber = AutoNumber('chapter');
Note: If the specified automatic numbering stream does not exist, the AutoNumber
constructor creates a numbering stream having the specified name. The
implicitly constructed stream renders automatic numbers as Arabic numerals.
To use a stream with different properties, create the stream explicitly, using a
createAutoNumberStream function of a Document object.