Text Variables

Tables of contents aren’t the only InDesign feature to extract content based on the styles applied to it. Text variables can be a convenient way to repeat or reference text that uses a paragraph or character style. Much of what you see along the tops of pages in the print edition of this book uses text variables to remind you of which chapter you’re reading (at the top of left-hand pages) and which topic (on right-hand pages).

Variables can also be a way to insert document data, like date and time of the most recent edit or output. And they can be used to extract and render metadata from placed images for captions. As in so much, there is good news and bad with this feature.

Chapter Numbers

When using the Book feature (discussed at the beginning of this chapter), you can inform each document which chapter it is or to begin automatic chapter numbering. To display the number, we insert a text variable: right-click and choose Insert Variable > Chapter Number. The chapter number will display in the same style as the text around it. Here is this chapter’s number: 7. (Yes, that “7” is a variable. I used the Book feature to set the first chapter of the Compendium section as “1.” This is the seventh.)

Another way to insert variables and, better, to define them, is by going to Type > Text Variables and choosing either Insert Variable or Define…. So I don’t redefine a variable I’m using, I’ll choose Define… and click New…. The settings above produce this:

Compendium Chapter VII (impressed?)

If I put that in a narrow text frame, however, it will look like this:

Warning: Text variables don’t break across lines. I bet you wondered when I’d get to the bad news. If the space available is too narrow, the variable text will get crushed.

If we redefine the variable to be less verbose, it will change everywhere and may fit in narrower quarters. Or I can select the variable, right-click, and choose Convert Variable to Text, and the following will result: it will wrap, but it will no longer update if the chapter number changes.

Captions

Of course, we can create our own captions, but if our images have metadata, we can generate captions that utilize it. Although we go through a different procedure for these, they, too, are text variables.

Metadata is added to images in one of several places. One can do so in Photoshop via the File Info dialog box. In Adobe Bridge or Lightroom, one can use a Metadata panel. For the image above, I added data to the Description and Creator fields. Object > Captions > Caption Setup… allows us to choose which metadata to include and what text should surround it in the caption we’ll later generate. To make the caption, I right-clicked a selected image and at first chose Captions > Generate Live Caption. The first problem was that InDesign didn’t read the Creator metadata. To force it to do so, I had to choose Author in the Caption Setup dialog—an obvious (and long-lived) bug.

Then I saw the result: the description was crushed on one line. If all my captions are very short, this may not be an issue. If a linked image’s metadata changes, the caption will automatically change as well. But few captions are short enough, and metadata like this doesn’t often change. So I used Undo, and this time right-clicked and chose Captions > Generate Static Caption. Static Captions are not variables, thus they are not linked to their source nor do they get crushed when the space is too narrow. Once these are generated, they’re just text.

Running Headers

These text variables are among the most useful. If you’re reading this in print, you’ll see a running header at the top of each page of this spread. One of them reads “Text Variables.” That one “sees” the last use of a particular paragraph style, which decorates the large header earlier in the text announcing this topic. Here’s it’s definition:

Using Type > Text Variables > Define…, I clicked the New button. I usually name a variable after the style to which it refers. I chose “topic title” and selected Running Header (Paragraph Style) as the Type. I have almost never used the character style variant. I’m sure it’s lovely.

For a running header, we are usually referring to a topic that is ongoing, and so we want the most recent use of it. Thus, I chose Last on Page for Use. We can choose a wide variety of special characters to automatically be added before or after the text we’re grabbing, or we may type into the Text Before or Text After fields. InDesign even supplies a thoughtful way to remove punctuation or change the case of the text.

To insert the variable, we locate our cursor in a text frame (for running headers, this is usually on a master page, and often near the Current Page Number marker), right-click, and choose Insert Variable > [name of variable].

Warning: Yes, another bug! When you change the text to which a variable refers, you’ll have to force the page to redraw. Simply zooming out and in again will do it. Otherwise, it appears that the variable is not updating.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset