About Arbortext Styler > Adding Generated Text > Labeling and Numbering Divisions
  
Labeling and Numbering Divisions
You can use Arbortext Styler to automatically number and label divisions, such as parts or chapters, in your documents using generated text. Note that Arbortext Styler can only generate numbers for title elements of division elements. So, for example, you can configure numbers for a title in chapter context but not for a chapter in book context.
If you want a division title to be numbered, its equivalent division context must also be present in the stylesheet, and styled accordingly. Numbering for that title will not work correctly if the title element appears in the stylesheet without its associated division. To achieve this, ensure you style your division to the actual number of levels present in your documents - Arbortext Styler will then create the title and division contexts for all those levels automatically.
Example: Labeling and Numbering Divisions
This procedure describes how to add generated text numbers to the title of each chapter in your document
1. In Arbortext Editor, open the transport.xml document located at Arbortext-path/samples/styler
2. Choose Styler > New Stylesheet to create a new stylesheet for the document. Accept the default settings in the Stylesheet Properties dialog box that appears.
3. In Arbortext Styler, select the chapter element from the Elements list.
4. Assign the Division style to the element via the Edit > Style menu option, if this is not already set for the chapter. The Division Details dialog box will open.
5. Set the required division level for the chapter, for example 1 if the document hierarchy is set up as root element/chapter.
6. Click OK to save the division setting and exit the Division Details dialog box.
7. In the Elements list, select the title in chapter context.
8. Go to the Generated text category, and select Number as the option in the Numbers and Bullets field.
9. Click the Details button next to the Number option. The Number dialog box opens.
10. In the Label field, enter Chapter followed by a space (and optionally any other settings you require). Leave the Label placement field set to Before number. This is the text that will prefix the number at the beginning of a chapter title. Note that the text and the number is shown in the Preview window of the dialog box.
11. Click OK to save the number setting and exit the dialog box. Note that the Before-text field in the Generated text category displays a preview of your title's numbering.
12. Choose Preview > Print.
In the Print Preview window, note that chapter titles are now preceded by the word “Chapter” along with the appropriate chapter number.
Example: Generating Compound Division Numbers
Here we will use a document with standard division numbering as defined in Labeling and numbering divisions above, but will change its generated text setting to produce compound numbering for its divisions and any child divisions within those divisions.
1. In Arbortext Editor, add a chapter element after the last chapter in the document, and specify Compound numbering as its title.
2. Add a sect1 element within the chapter element you just added, and specify First sect1 as its title.
3. Add a sect2 element within the sect1 element you just added, and specify First sect2 as its title.
4. In Arbortext Styler, select the sect1 element from the Elements list.
5. Assign the Division style to the element via the Edit > Style menu option, if this is not already set for the section. The Division Details dialog box will open.
6. Set the required division level for the section, for example 2 if the document hierarchy is set up as root element/chapter/sect1.
7. With the sect1 element still selected in the Elements list, go to the Breaks category.
8. Select No change from the drop down list in the Start new field.
9. Back in the Elements list, select the title in sect1 context
10. Go to the Generated text category.
Note that the Before-text field has a number sign (#) followed by a period and a 1. The number sign and period indicate that the number of some element in the previous level and a period will precede the number of the sect1 element, which is indicated by a 1. In the next step you will select the element whose number will form the first part of the sect1 number.
11. Select the Number option then click on Details button. The Division Title Number dialog box opens.
12. In the Previous level number field, select chapter from the drop down menu. Here you have selected that the number of the chapter in which the sect1 appears will form the first part of the sect1’s number.
Note that the value of the Number format field has now changed from #.1 to 1.1.
13. In the Label field, enter Section followed by a space (and optionally any other settings you require). Leave the Label placement field set to Before number. This is the text that will prefix the number at the beginning of a sect1 title. Note that the text and the number is shown in the Preview window of the dialog box.
14. Click OK to save the numbering setting and exit the dialog box. Note that the Before-text field in the Generated text category displays a preview of your sect1 title's numbering.
15. Select the sect2 element from the Elements list.
16. Assign the Division style to the element via the Edit > Style menu option, if this is not already set for the section. The Division Details dialog box will open.
17. Set the required division level for the section, for example 3 if the document hierarchy is set up as root elementchapter/sect1/sect2.
18. With the sect2 element still selected in the Elements list, go to the Breaks category.
19. Select No change from the drop down list in the Start new field.
20. Back in the Elements list, select the title in sect2 context.
21. Go to the Generated text category.
Note that the Before-text field has a number sign (#) followed by a period and a 1. The number sign and period indicate that the number of an element in the previous level and a period will precede the number of the sect2 element, which is indicated by a 1. In the next step you will select the element in the previous level that will provide the first part of the sect2’s number.
22. Select the Number option then click on Details button. The Division Title Number dialog box opens.
23. In the Previous level number field, select sect1 from the drop down list. Here you have selected that the number of the sect1 in which the sect2 appears will form the first part of the sect2’s number.
Note that the value of the Number format field has now changed from #.1 to #.1.1.
24. In the Label field, enter Section followed by a space (and optionally any other settings you require). This is the text that will prefix the number at the beginning of a sect2 title. Note that the text and the number is shown in the Preview window of the dialog box.
25. Click OK to save the numbering setting and exit the dialog box. Note that the Before-text field in the Generated text category displays a preview of your sect2 title's numbering.
26. Choose Preview > Print.
In the Print Preview window, go to the last page in the document. The numbering of Chapter 7 and its subsection titles should look as they do in the following graphic (note that the styling of the titles and their numbers may differ depending on the settings specified in the print output version of your stylesheet):
This is an image of a document fragment, showing the chapter title “Chapter 7 Compound numbering”, the title “Section 7.1 First sect1” on the next line and the title “Section 7.1.1 First sect2” on the third line
If a title’s number is set to include the previous level number, but the element at the previous level is not a numbered element, you will see a message similar to that shown below during publishing:
[A30390] ERROR: Cannot get previous level number. Element "chapter" is not numbered.
Double-click on the message to find the element for which Arbortext Styler attempted to include the previous level number. Instead of the previous level number, a question mark will appear.
Example: Generating Page X Of Y Numbering for Individual Divisions
The steps contained in this topic demonstrate how to generate a “page x of y” numbering style for the divisions in a document, where y is the total number of pages in the division.
There are several assumptions and restrictions that accompany numbering of this type, meaning that the numbering can be achieved in certain specific contexts:
The numbering will appear in a header or footer of a document intended for print or PDF output, generated by any of the three available print engines (note the limitation for FOSI output below).
FOSI print output based on double sided page output, where there can be blank pages at the end of a division, may not format correctly
This procedure instructs you how to generate scoped page numbering for divisions of a document, where the document is split into divisions that are based on the <preface>, <chapter> and <appendix> elements. Page numbers will restart at 1 for each of the divisions, and the text Page x of y will appear in the footer for each division, where x is the page in the division and y is the total number of pages in the division.
Note that in this procedure, each of the three division elements uses the same page set so the numbering needs only to be set in the footers for that one page set, with the three scoping divisions declared in the numbering dialog box (see step 8). If the divisions use different page sets you will need to repeat the procedure individually for each division and its page set/footers.
1. In Arbortext Editor, open the transport.xml sample document located at Arbortext-path/samples/styler.
2. Choose Styler > Edit Stylesheet to edit the default stylesheet for the document. This is a read-only stylesheet so you will need to save a local copy to make any changes.
3. Place your cursor before the first chapter element in the document, and add a preface element. Give it a title and add some content.
4. Place your cursor after the last chapter element in the document, and add an appendix element. Give it a title and add some content.
5. In Arbortext Styler, assign the main body page set to the preface, chapter, and appendix elements, including the following settings for each in the Breaks category:
Start new: Page
Page setName: mainbody-page
Page number: Initial
Note: ensure that the Outputs to Edit field is set to Print/PDF for each element, as numbering of this type only applies to print and PDF documents.
6. In the Page Sets list The Page Sets list icon - an open book edged in blue, select the main body page set. Navigate to the Page types category and note that the page set is set to use the main body right and main body left page types.
7. In the Page types list , select the main body left and main body right page types. Note that they are set to use the main footer footer object.
8. In the Page regions list , select the main footer footer object. Go to the Text category and note that the footer object is set to display content generated by the page number center Generated Content object.
9. In the Generated Contents list , select the page number center object. Click the Edit button in the edit pane to open the Generated Text Editor.
10. Carry out the following steps to set the numbering for the footer:
a. Add the text Page, followed by a space, before the FormattedPageNumber element.
b. Add a space, followed by the text of, followed by another space, after the FormattedPageNumber element.
c. Select the menu option Insert > Final Page Number to insert the final page number of the division. The Final Page Number dialog box opens.
d. In the dialog box, select the Division radio button then use the Add button to move appendix, chapter, and preface from the Available elements list to the Selected elements list.
Use the CTRL key to select multiple elements.
e. Click OK then File > Apply and Close to complete the numbering.
11. Choose Preview > Print to generate a print preview of the document. You will see that the footers in the document contain the text Page x of y, with the numbering being restarted in each division.
Once you have set numbering in this way in the transport.xml document, you will note that the entries for each division in the table of contents at the beginning of the document are numbered 1. This is intentional. You may need to customize the content of your table of contents if you want to display more continuous numbering, for example including numbered sections within the division. See Customizing the Content of a TOC for further information.
Example: Generating Titles for Divisions Without Title Elements
The procedure shown below describes how to generate titles for the divisions in your document if they do not contain specific element titles in which the title can be included or generated. This procedure will work if your document is split into semantic divisions, i.e. a different element is used for each division in your document. For example, your DTD may define the elements introduction, subject, description, and summary as fixed divisions that must occur in a certain order in the document. These elements do not contain a child title element and as such must each generate their own title to appear at the beginning of the division.
It is assumed in this procedure that the introduction, subject, description, and summary elements have been styled as Division in the stylesheet.
1. In the Elements list, highlight the introduction element. Navigate to the Generated text category for the element (or the relevant context, if applicable).
2. In the Before-text field, click the Edit button to open the Generated Text Editor. Choose the Insert > User Formatting Element menu option to select an existing User Formatting Element (UFE), or create a new one, to be used to format titles, for example _ufe:Title.
3. Enter within the UFE tag the title you want to generate for the introduction element. Click File > Apply and Close to save the generated text setting and exit the editor. You have now created the title for the introduction element, and wrapped it in a UFE. In the next step you will style the UFE as a title, to ensure that the generated text you entered for the introduction element is treated as a title. Completing this step will enable you to include the divisions in a table of contents for your document if required, even though they do not contain an explicit title element. Refer to Customizing the Content of a TOC for information on how to set up your table of contents in this way.
4. Highlight the _ufe:Title element in the Elements list, and give it the Title style via the Edit > Style menu option.
5. Create a context for the UFE anywhere within the introduction element. Note that you must create the context by specifying the introduction element as the ancestor of the UFE, rather than its direct parent. This is because you specified that the title of the introduction element is created via generated text, which generates its own wrapper based on a Styler Formatting Element (SFE). You then wrapped the title again, this time in the _ufe:Title UFE for which you are creating the context. This sets the markup of the title in the introduction element as shown below:
<introduction>
<_sfe:BeforeOrAfterText>
<_ufe:Title>Introduction</_ufe:Title>
</_sfe:BeforeOrAfterText>
</introduction>
If you attempt to create a context of the UFE with the introduction element as its direct parent, you will be presented with a dialog box asking you to confirm that you really wish to proceed and giving you the option to insert introduction as an ancestor instead.
This is an image of a Styler message dialog box, showing error type A23731 that advises that you may wish to change introduction to an ancestor of _ufe:title
6. Repeat steps 1–3 and 5 for the remaining divisions in your document. In addition to the semantic division elements with their generated titles, you should now have one UFE (_ufe:title) and a context of that UFE within each semantic division element/context.
7. Choose the Preview > Print menu option. In the Print Preview window, note that your divisions appear in the correct order and that each one has its own generated title.
8. If you want to number the divisions consecutively as well as creating their titles, you will need to create a custom counter and assign it to each context of the _ufe:title UFE you created for the semantic divisions. The following steps describe how to accomplish this:
9. In the Elements list, select the required context of _ufe:title in the semantic division. Set it to be numbered by navigating to the Generated text category and selecting the Number option in the Numbers and Bullets field.
10. Click the Details button to open the Division Title Number dialog box.
11. In the dialog box, navigate to the Custom counter drop down menu. If you are carrying out the step for the first time in this procedure, create a new counter by selecting (new) from the menu and entering the name of the custom counter when prompted, for example semantic-divisions. If you are repeating the step for subsequent divisions in the same counting sequence, select your custom counter semantic-divisions in this drop down list. Exit the dialog boxes to return to the Elements list.
12. Repeat steps 9–11 for the other contexts of _ufe:title in the semantic divisions that are to be included in the division counting sequence.
13. When previewing or publishing you will now see that the semantic divisions in the document are now numbered consecutively, as well as including a generated title each.