How to Type “The Last Page Number in a Book”
You already know that InDesign has a “the last page number” text variable, right? To get that, you choose Type > Text Variables > Insert Variable > Last Page Number. And because it’s a variable, it automatically updates if the last page number of that document changes. Cool!
But what if you want “the last page number in a book” — that is, not the last page number in this document, but in the last file in a book panel? InDesign doesn’t have a variable for that.
(By the way, one reason why it doesn’t is that the same document can be in more than one book. I usually don’t recommend doing that, but if you did do that, the text variable would get mighty confused as to which book you were talking about.)
Okay, so there’s no variable, but sometimes we really need to grab that number. For example, if your headers are supposed to read “Page 1 of 28” or something like that. Here’s the secret: Use cross-references.
In order for a cross-reference to work, you need to point it to some text or a text anchor. I usually just throw a piece of text in a frame on the last page, like this:
And you need to apply a paragraph style to that text. It doesn’t really matter what you use, but I make a style just for that one paragraph. Also, make sure that the text is in a frame that is set to Nonprinting in the Attributes panel (so it won’t print). I did that in the frame above, but you can’t see it in the panel because I have the text cursor inside the frame. (If I had clicked on the frame with the Selection tool, you’d see Nonprinting selected in the Attributes panel.)
Now, back in your other document, you can use that page number by creating a cross-reference in the Cross-References panel. First you place your cursor where you want the page number to be displayed (I’ve put it inside a text frame in the header on my master page):
…and then when you click the New Cross Reference button, you can choose your “last page” paragraph:
To select that paragraph, I chose the last document of the book in the Document pop-up menu of the Destination section, and then I chose the paragraph style, and then I clicked on the paragraph I wanted to point to. Finally, note that I’m choosing Page Number from the Format pop-up menu. That means I will only get the page number in my cross-reference.
When I click OK, InDesign inserts the page number into the text frame:
Of course, then if I later change the number of pages in any of my documents, the cross-reference will update automatically. See, here I have added 2 pages to chapter 1:
Important note: When you add the page numbers, the cross-reference page number doesn’t update on your page immediately! You sometimes need to give it a few seconds and you need to change the screen view. That is, it won’t update on screen until you change from one page to the next, or zoom in and out, or do something else that forces the screen to redraw.
Editing the Cross-Reference
[I'm adding this section a few days after writing the text above because I just realized I didn't finish the process above.]
If you look closely, you'll see that the "Page Number" cross-reference we used above shows up as "page 14" -- that is, it actually shows the word "page" and we don't want that. Fortunately, it's easy to get rid of by editing the x-ref you made.
First, double-click the x-ref inside the Cross References panel, to open the Edit Cross-Reference dialog box. Then click the little pencil icon next to the Format pop-up menu. This lets you change how the cross-reference shows up on your page.
In the Cross-Reference Formats dialog box, choose Page Number in the list on the left, and then click the + (plus) button at the bottom, which duplicates it. Now change the name, and remove the word "page" in the Definition. It should look like this:
After you click OK, make sure your new format is selected inside the Format pop-up menu of the cross-references dialog box… then click OK. Now your page number should appear without the word "page" in it, like this:
Whew! The good news is that you only have to do this once. From then on, you can copy and paste this text frame to the master pages of your other book documents. And once you make that cross-reference format, InDesign remembers it for other documents, too.