Thanks for coming to, the world's #1 resource for all things InDesign!

Adding the Last Page Number in a Book to Text

It’s probably a bad idea to write blog posts on an empty stomach because all I think about is how using InDesign is a lot like cooking…

Anyway, one of the cardinal rules in my kitchen is that the best tools are the most versatile ones. Sure, I did once buy a combination avocado pitter and masher. But it ended up in the trash as I found guacamole came out just as good when I used a fork. Likewise, some of my favorite InDesign tools can be used for all kinds of purposes. Take for example cross-references. In issue 95 of InDesign Magazine, Peter Kahrel showed how to use cross-references to overcome all kinds of tricky problems with footnotes. You can also use cross-references to do cool stuff like automatically type the last page number in a book, which is not possible to do with a text variable since the scope of text variables is limited to the current document. Here’s how to do it.

1. Add a destination text anchor on the last page in the book.

Open the document containing the last page in the book.

Go to the last page of the document and create a text frame somewhere touching the page.

In either the Cross-References panel or the Hyperlinks panel menus, Choose New Hyperlink Destination.

Choose Text Anchor for the Type and give it an obvious name, like “last page in book”.

2. Create the cross-reference

In any of your book documents, put your cursor where you want the last page number to appear, and insert a cross-reference.

In the Cross-references panel, click the button to create a new cross-reference.

In the dialog box, link to a text anchor and choose the one you added to the last page of the last document in the book.

3. Customize the cross-reference format

Change the cross-reference format so it only shows the page number where you put the text anchor. In the dialog box, click the pencil icon.

Then click the + button to create a new cross-reference format.

Call it “last page” or something similar.

In the Definition field, enter <pageNum /> exactly. This will insert just the page number of the text anchor wherever you insert the cross-reference in your text.

When you close the dialog box the last page number of your book will be inserted in the text.

Even cooler, as long as you make sure the text frame containing the text anchor is always on the last page of the book, you can add or delete pages in any book document, and the cross-reference will always display the correct number.

Tasty! Now, who wants guacamole?

Mike Rankin

Mike Rankin

Editor in Chief of, InDesign Magazine, and Author of courses on InDesign and Illustrator. Husband. Dad. Dog walker.
Mike Rankin

Latest posts by Mike Rankin (see all)

  • - November 30, -0001
Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *