# totalpages element

Type: | Images and Specials
Attributes: | size • type
See: | pagenumber

The totalpages tag prints the total number of pages in the current document. It's commonly used with the pagenumber element. The totalpages tag may not have any children. The sizing for this element is a little unusual in that the Report Generator has to take a guess as to how many characters are required. By default this is three, but it may be set to another value by setting the size attribute.

A simple footer that prints the current and total number of pages.

    <head>
      <macrolist>
        <macro id="myfooter">
          <p align="center">
            Page <pagenumber/> of <totalpages/>
          </p>
        </macro>
      </macrolist>
    </head>
    <body footer="myfooter" footer-height="2em">

This shows the IDREF attribute to print the page of a named element

    <h1>Table of Contents</h1>
    <table>
      <tr><td>Chapter 1</td><td><pagenumber idref="chapter1"/></td></tr>
      <tr><td>Chapter 2</td><td><pagenumber idref="chapter2"/></td></tr>
    </table>

    <h1 id="chapter1">
    <p> Chapter 1 goes here </p>

    <h1 id="chapter2">
    <p> Chapter 2 goes here </p>

This shows how to print the current page in roman numerals

    <pagenumber type="lower-roman"/>