Headers and Footers: Part 2
In this section, we describe how to create the following types of headers and footers:
For each document section, odd-numbered and even-numbered pages can be assigned different headers/footers.
To create different headers for odd-numbered and even-numbered pages, click the Add Header/Footer link in the title bar of the respective document section, and select Add Header Odd and Add Header Even from the menu that pops up (screenshot below). This creates two header templates, one for odd-numbered pages, the other for even-numbered pages. Enter the content of the two headers in the templates.
Separate footers for odd-numbered and even-numbered pages can be created in a similar way to that described above for headers.
Different headers/footers can be created for each document section of the document. To do this, click the Add Header/Footer link of the Initial Document Section or the Document Section title bar. This pops up the Add Header/Footer menu shown in the screenshot above. Note the following points:
•Headers/footers for odd-numbered and even-numbered pages can be added separately, or a common header/footer can be added for all pages in the document section.
•An additional first-page and/or last page header/footer can be added. These headers/footers will be used on the first and/or last page of the document section instead of other headers/footers that might be defined for that document section.
•Page numbering for the document section can either run on from the previous document section or start at a designated number.
•The Page Total is the page count of the entire document not that of the current document section.
Headers and footers can be designed manually inside a layout container. The approach would be to design a single page as a layout container. The header and footer are created within static tables located, respectively, at the top and bottom of the page. If more than one page is to be designed, then multiple layout containers can be used, each separated from the next by a page break (Insert | Page / Column / Document Section | New Page).
When a document contains a list of numerical items that must be totalled and the list extends over multiple pages, subtotals of each page and/or running totals might be required to appear in the headers and/or footers of each page. The Subtotals.sps example, which is in the (My) Documents folder, C:\Documents and Settings\<username>\My Documents\Altova\StyleVision2022\StyleVisionExamples\Tutorial\Subtotals\, demonstrates how running totals can be created and included in headers and footers.
The following strategy was used to design this SPS:
•Because the listing is in a table and because a table cannot be made to auto-fit a printed page, the number of rows that must be accommodated on a page must be specified. These numbers are given in two variables that have been defined on the top level template, that for the \$XML template; they are named RowsOnFirstPage and RowsPerPage.
•The page count is derived by dividing the total number of list items by the number of rows per page (adjusted to take account of the different number of rows on the first page). The page count is stored in a variable called CountOfPages (defined on the \$XML template).
•A user-defined template is created for the sequence 1 to \$CountOfPages, and a static table is created within this template. Defined on this template are two variables that calculate the which row is to be the first row (\$RowFrom) and the last row (\$RowTill) on each page. The rows in the table are generated by a user-defined template, which selects the items in the XML file (file elements) on the basis of their position with respect to the \$RowFrom and \$RowTill values. If the position of the file element is an integer value that lies in the range delimited by values of the \$RowFrom and \$RowTill variables of the current page, then a row will be generated for the current file element.
•The running totals are generated with Auto-Calculations and inserted into rows at the top and bottom of the tables. Note that the XPath expressions to generate running totals at the top and bottom of pages are different from each other.
•Headers and footers are created in tables, respectively, above and below the main table on the page. The Auto-Calculations to generate the running totals are inserted in the header and footer templates.
•A page break is inserted at the end of each page.