What the heck is a text variable, anyway? It’s copy that you can add anywhere in your document—but it varies depending on the context. For instance, you could set up your document to automatically insert the current date in a header. Or if you need to send readers to the last page, a text variable will automatically update the page number reference if you add or delete pages later.
Now think how useful text variables could be as navigational tools (i.e., running heads) in a nonfiction book. They can make the current chapter number and chapter title appear—presto!—on verso pages and the most recent internal heading appear on recto pages. And that’s exactly what I’m going to demonstrate in this article. Adobe’s official user guide instructions on the topic of text variables are a bit sketchy, so I’ve developed a detailed lesson for you.
In chapter 52 of Book Design Made Simple, we explain how to create a separate parent (previously called master) page for each chapter in your book. But with text variables, you can use A-Parent (previously A-Master) for all your chapters instead, as demonstrated below. It’s simpler and less cumbersome.
This lesson covers the following topics:
- How to create text variables
- How to apply text variables
- Other uses for text variables
- Automatic page numbers
How to create text variables
Before working with text variables, set up your book’s paragraph and character styles. They don’t have to be final; for now, at least assign a style name to each element. (You may change the styles later on.) Once you’ve done that, you can define (create) the text variables, which means to set up what you want the variable to say. We’ve developed a sample book to use for this exercise. Below you can see what a chapter opening page looks like, with our paragraph style names labels in red.
Chapter number text variable
To define the chapter number as a text variable to use in your verso running head, do the following:
- Put your cursor in any chapter number.
- Go to Type > Text Variable > Define.
- Select New.
- Use the settings shown below. The “Type” category indicates the way you are going to use the text variable, not the kind of copy that it is now—so select Running Header (Paragraph Style). You can add text before or after the number in your running heads; for instance you might want to add “Chapter.”
- Click OK.
Chapter title text variable
Next you’ll define the chapter title text variable for use in verso running heads just after the chapter number.
- Put your cursor in any chapter title.
- Go to Type > Text Variable > Define.
- Select New.
- Use the settings shown below. In this example we decided to add 3/4 of an em space between the chapter number and the chapter title. Because this equals an en space plus a quarter space, the final result in the Text Before field becomes ^>^4.
- Click OK.
Internal heading text variable
Now you want to make your recto running heads show the latest internal heading of the current spread. In our sample book we call these h1 heads, shown below. (Notice that there are no running heads on the pages yet.)
Define the text variable the same way as for chapter numbers and chapter titles. In the Use field, select Last on Page in order to make the head read “Dozing Off” and not “Down, Down, Down.” See below:
By the way, if there’s no heading on the next spread(s), the running head will continue to read “Dozing Off” until a new heading appears.
Going a bit further
What if you don’t want to include your entire chapter title or heading in the running head? InDesign guru David Blatner has pointed out a sophisticated but simple way to create text variables that exclude unwanted parts of your chapter number or title, such as dashes or extra words. Check out his instructions in InDesign Secrets. Thank you, David!
How to apply your text variables
Now that you’ve defined your text variables, you’ll be eager to try them out in your running heads. First make the text frame for the running heads on your Parent (Master) pages, and paragraph styles for them. Then put the cursor in each text frame and insert the text variables by going to Type > Text Variables > Insert Variable, and choose the one you created a moment ago. If you’re using two in the same running head, as in our example, keep your cursor in place and complete the step a second time. Here’s approximately what your running head text frames should look like on your Parent (Master) pages:
And this is the result on a random text page, in this case in Chapter 3:
If the copy in a chapter title or an internal heading (h1) is too long to fit in the running head text frame, the result will look something like this:
Oops—you’ll have to take out some words to make it fit on one line. With your cursor, delete the text variable on the relevant page(s) and then type in your shortened running head. (In case you’ve forgotten, you can select a glued-in-place parent (master) page item by holding down Shift+Ctrl/Cmd while clicking with the Selection tool or the cursor.)
Other uses for text variables
Text variables can automate any of your copy that changes according to context. Think of your running heads in #nonfiction, for instance. https://tinyurl.com/y8tutxxy Share on XYou can use text variables to refer to chapter numbers or titles throughout your text. And then if you change the number or title of a chapter at some point, the reference in the text will change, too.
You can use a text variable as a placeholder for any recurring copy, such as the title of a companion book that you’re still writing. (When you define the text variable, choose Custom Text in the Type field.) Then once you’ve finalized the companion book’s title, you simply change the custom text of the variable, and bingo—all references to it will be correct.
You can even use text variables to create your table of contents, but it will be complicated. We advocate using the InDesign automatic table of contents feature for that—see pages 240–244 of Book Design Made Simple for detailed instructions.
Before you start, though, you should probably review this video from InDesign Secrets. It shows even more uses for text variables but also cautions you about some limitations to this otherwise great feature.
Automatic page numbers
You could certainly insert automatic page numbers by using text variables. But InDesign has another feature just for this purpose, and it’s simpler to use:
- Put your cursor in the text frame you’ve made on one of your Parent (Master) pages for your folio (page number).
- Go to Type > Insert Special Character > Markers > Current Page Number.
The letter A will appear in the folio text frame, assuming that you’re in your A-Parent (A-Master) page. (B will appear on your B-Parent (B-Master) page, etc.)
Repeat the procedure for the folio on the other parent (master) page in the spread.
And you’re done. All of your pages based on Parent (Master) page A will show the current page number. How easy was that?
* * *
I would like to thank Anne-Marie Concepcion of InDesign Secrets for pointing out this wonderful feature that has been a part of InDesign just about forever but that was new to me. As soon as I heard about it, I just had to find out more and share it with you.
Read more: Book running heads » will help you decide what copy to put in your running heads.
Read more: Front matter » lists what to include in the front of your book.
Read more: Back matter » suggests what to include in the back of your book.
Book Design Made Simple. You can do it yourself.
Chris Metcalfe says
Thank you for this article, you’ve explained running headers very clearly.
I’m stuck on one point though: I’m trying to duplicate an existing document style where the section name appears in the header of every page but isn’t in the main text. There is no ‘section title’ style on which to base the running header.
I see two possible solutions, but I’m very new to InDesign and not sure which is better, or if there are other alternatives I’m not aware of.
Option 1: Create a master page specifically for the beginning of each section that uses a real header in place of the running header, and use a master page with a running header everywhere else.
Option 2: Include an ‘invisible’ section title at the beginning of each new section. Perhaps make the text white? Or hide it on a non-printing layer?
What are your thoughts?
Glenna Collett says
Dear Chris,
You have picked up a lot of knowledge about InDesign already, which is great. I think that either of your options would work just fine. In option 2, I think you’d better leave the invisible section title on a printing layer; I’m pretty sure that if you put it on a non-printing layer it will disappear altogether.
I would have thought of the same two solutions and don’t have any other ideas at the moment. I congratulate you on your creative thinking!
Glenna
Veronica says
I am using a text variable in the footer. That is working great BUT I want it to also be used throughout the document. I have the Client Name as the title of the document. I want to personalize the document throughout. I want to insert the in body copy and disclaimer copy replacing it with the real name. The names are usually long. It is inserted into paragraphs that flow. It isn’t at the line break but it still looks like badly justified copy (instead of flush left copy). In this case, is there another solution instead of text variable?
Glenna Collett says
Hi Veronica,
What I think you’re saying is that you want to use text variables inside your text, not simply in your running feet. That is very doable and is covered in the “Other uses for text variables” section of the blog post. If the copy comes out poorly justified, be sure that your text variable paragraph style is set up as flush left the way you want it. If this doesn’t work (and I’ve found that text variables are sometimes uncooperative), you might have to use the Find feature within your text and fix each instance to your liking.
If you don’t want to use the text variable feature for this, simply typeset a key word or phrase where the real copy will be substituted in later, maybe some silly word or phrase that you wouldn’t normally use, such as “merry-go-round” or just “nonsense!!!phrase.” Then later you’ll use the Find feature and sub in the correct copy. When you’re done, just double check to make sure you found every instance. Personally, I’d find this method more reliable.
I hope this reply comes in time to help you. Best of luck.
Glenna
Meredith says
Hi, this is super helpful and informative. I have my running headers set up for chapter title and book title on the left and right side pages. I dont want these headers to appear on chapter title pages, as I visually prefer a clean page for the first page of the chapter. Is there a way I can make headers start on the second page of each chapter, or could I manually delete the header from each first page? Thank you!
Glenna Collett says
Hello Meredith,
There are two ways to deal with this.
The first, most organized way would be to make a master page for chapter openers. This master page would have no running head (a chapter opener page should never have one anyway), and probably a page number at the bottom of the page.
The second way would be to delete the running head by hand. You can select a master page item by holding down Control or Command + Shift while selecting it. Then delete it. The only problem with using this second method is that if your chapter opener page moves because of added or deleted material, you’ll have to remember to reinstate the running head on the page you deleted it from.
I hope this helps. Good luck with your book!
Glenna
Meredith says
Thanks Glenna, helps a lot 🙂
dave says
You would think a site on book design and typography would use body copy with sufficient contrast on its website 😉
#a5a5a3 is hard to read and falls far short of accessible contrast ratios https://webaim.org/resources/contrastchecker/?fcolor=CCFFFF&bcolor=075290
Fiona Raven says
Dave, we knew the light grey text was hard to read, but didn’t know how to change it. You gave us the push we needed to finally figure out how to change the text to black. Thanks!
ben edwards says
Hi, this is an extremely helpful and interesting website. I have a question about text variables in books. In my front pages, I have the document title and description (for instance, Project Dragon, Information Memorandum, each separate paragraph styles). In subsequent documents in a book, in my running header (in the masters) I have created a running header based on a defined text variable (based on a paragraph style) for a running header which refers to Project Dragon, Information Memorandum (in the front pages document), but i just get blanks in my running headers in each of the other book documents (somehow it is not picking up from the front pages document). Any ideas?
Glenna Collett says
Hello Ben,
We’re very glad you’re finding our site useful. And it’s always interesting for us to discover the problems that folks run into as they work on their books. So let’s see if I can help with this one.
It sounds as if you are producing a set of sections that you are going to put together into a book at the end, by using the InDesign Book feature. At the moment, all the sections are separate. Is that right? If so, my advice is to do the following:
1. Make absolutely sure that the relevant paragraph styles in all the sections are precisely the same. If you haven’t figured this out already, you can Load paragraph styles from one document to another one with a couple of clicks in the Paragraph Styles panel. That ensures that the styles are precisely the same in both documents.
2. It does seem that the other docs are not picking up the copy from the original one, and that is logical since they are not all linked together yet. So I’d add a text frame somewhere in the current doc–it could be on the pasteboard–and type in Project Dragon, Information Memorandum. That way, the text variable has some copy to work with.
Let us know if that works. Or not.
Good luck with your book project, Ben! Thanks for reading, and for reaching out.
Glenna, coauthor
dnaielle says
i’m creating an encyclopedia type book and the client would like the running head to list the first entry on the spread to the last entry on the spread instead of page per page. is there a way to create a variable with “first and last on spread” instead of by page?
Glenna Collett says
Hi Dnaielle,
Thanks for your interesting question. I did a little digging in the Adobe forum, and someone there came up with a brilliant solution to your problem for a very similar kind of book. I’m copying here what was said:
HERE’S THE QUESTION:
Text variable for “first on spread” possible?
I am working on a book where the content is basically a list of things, such as, say:
[Page 20]
Jack: A boy’s name.
Jane: A girl’s name.
Joe: A boy’s name.
Etc.
[Page 21]
Justin: A boy’s name.
Kevin: A boy’s name.
The lefthand page running head shows the book’s title. The righthand running head is supposed to show the range of content for the *spread*. In the example above, since “Jack” falls at the top of (lefthand) page 20, and “Kevin” falls at the bottom of the (righthand) page 21, the righthand page running head should read “Jack-Kevin”. (It’s obvious enough how to use nested character styles to pick out just the names.)
My question is: Is it possible to define a text variable that will pick up NOT “first on page” but instead “first on spread”? Because the only thing I seem to be able to achieve is “Justin-Kevin”.
I tried putting a text variable on the lefthand pages in a special style sheet in invisible type, and then making the right hand variable pick up *that* content based on the style, but I guess you can’t make text variables out of text variables–unless someone else can think of a clear hack for it
Thanks!
AND HERE’S THE ANSWER:
Hi Charles,
There is no “first on spread” option for text variables, as you have found.
What you can try doing though, is to stretch the text frame on the master page so that its left edge is actually on the verso (left-hand) page. Obviously have the text variable itself right-aligned so that it appears on the right-hand page. IIRC, the text variable will then pick up the text from the left-hand page, even though it will be displayed on the right-hand page.
But if you then need to display the last word on the recto, you’ll need to create a separate text frame on the master page that does not stretch over to the verso. Then put the two frames next to each other on the master so that the spacing is right…
HTH,
Ariel
I hope this helps. It’s logical but will be a little difficult to make it look good. Good luck with your book, and let us know if this solution works for you.
Glenna