Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Adobe Creative Suite

Text Variables in Adobe InDesign CS3

Text variables in InDesign provide a way for you to insert text that can change depending on various factors, such as times, dates, and page references. Olav Martin Kvern and David Blatner discuss them here in this excerpt from their book.
Like this article? We recommend

Like this article? We recommend

Text Variables

Believe it or not, we’ve met a number of graphic designers who are scared of the word “variable.” It’s not that frightening—a variable is simply something that can change. Text variables in InDesign provide a way for you to insert text that can change depending on various factors, such as times, dates, and page references. In a way, the automatic page number special character is a sort of text variable, because it changes depending on the page on which it appears. You’re not scared of the automatic page number marker, are you?

It’s important to understand the difference between text variables and text variable instances. A text variable is the definition of the variable itself; a text variable instance is the marker in the text that inserts the content of the text variable. It’s entirely possible to have a text variable in a document for which no text variable instance exists in the layout (though there’s really no reason to).

Text variables come in a variety of flavors, and are subject to a variety of limitations. First, let’s take a look at the text variable types InDesign supports.

  • Chapter Number. A text variable that refers to the number of the current chapter (chapter numbering is defined by the book containing the document—for more on books, see Chapter X, “Long Documents”).

  • Creation Date. A text variable that refers to the date and time you created the document (not when you made the variable).

  • Custom Text. A string of any text you can type.

  • File Name. The name of the document.

  • Last Page Number. The number of the last page in the file.

  • Modification Date. The date and time of the last modification made to the document.

  • Output Date. The date and time the document was printed.

  • Running Header (Character Style). Refers to the first or last instance of text on the page containing the text variable instance that has been formatted using a specified character style.

  • Running Header (Paragraph Style). Refers to the first or last paragraph on the page containing the text variable instance that has been formatted using a specified paragraph style.

Text variables provide a number of features InDesign users have long wanted, such as the ability to add running headers and footers that are based on the first or last instance of a given paragraph style on a page. If you work on books, as we do, you’re probably curious about using text variables for cross references—this is where the “limitations” we mentioned earlier come in. You can’t refer to an arbitrary string of text using text references, which means that you can’t use them for cross references to your figure numbers, or to other sections of a book.

Worse, in some ways, is that text variables are considered as a single character for purposes of text composition. This means that InDesign will not enter a line break inside a text variable instance. This was already true for the composition of section markers and automatic page numbers, but it can be even more of a problem with text variables because they usually contain a longer run of text (see Figure 3-35).

Don’t get us wrong—text variables are a great thing. But we point out the problems because we think it’s important that you understand how they work. Before you’re on a deadline.

Showing Text Variable Instances

When you want to see when text is a text variable instance, choose Show Hidden Characters from the Type menu. InDesign will display a (very pale!) box around each text variable instance in the text (see Figure 3-36).

Text Variable Options

Each type of variable has its own options. For example, most of the text variable types give you the option of adding text before and/or after each text variable instance, but almost all of them provide other options, as shown in Table 3-3.

Text Variables

Variable Type

Option

Definition

All Formats (except Custom Text)

Text Before

Text to enter before the text variable.

Text After

Text to enter after the text variable.

Chapter Number

Numbering Style

Choose Arabic (1, 2, 3), lowercase Roman (i, ii, iii), uppercase Roman (I, II, III), lowercase letters (a, b, c), or uppercase letters (A, B, C).

Custom Text

Text

Enter the text you want to have appear in the text variable instances.

File Name

Include Entire Folder Path

Set this option to true to include the full path to the document file.

Include File Extension

Set this option to true to include the file extension of the document file.

Last Page Number

Numbering Style

Choose Arabic (1, 2, 3), lowercase Roman (i, ii, iii), uppercase Roman (I, II, III), lowercase letters (a, b, c), or uppercase letters (A, B, C).

Scope

Choose Section to specify the last page in the section; choose Document for the number of the last page in the document.

Creation Date, Output Date, Modification Date

Date Format

Enter a date format by selecting items from the pop-up menu. You can enter spaces or punctuation between the time/date placeholders. See Table 3-4 for a list of the placeholders (you can simply type them, rather than having to choose them from the menu).

Running Header (Character Style), Running Header (Paragraph Style)

Style

The character or paragraph style to use.

Use

Choose Last on Page to use the last instance of the style on the page, choose First on Page to use the first instance.

Delete End Punctuation

Remove the punctuation at the end of the text, if any.

Change Case

Choose a case option for the text that will appear in the text variable instances. You can choose uppercase, lowercase, sentence case, or title case.

Inserting a Text Variable

Before we get into the details of how to create your own variables, let’s look at how you can insert a variable at the current cursor location. Assuming that you have an active text insertion point in a text frame or story, choose the name of the text variable from the Insert Variable submenu of the Context menu (see Figure 3-37) or from the Insert Variable submenu of the Text Variables submenu of the Type menu. InDesign adds the text variable instance.

Creating a Text Variable

The preset text variables are all well and good, but the real fun lies in defining your own. Maybe you just want a more formal time and date format, or maybe you want to enter a custom text variable—either way, it’s easy, and the range of possible text variables is vast (even within the limitations we mentioned earlier).

Date Format Shortcuts

Category

Type

Placeholder

Example

Time

Hour (1-12)

h

1

Hour (01-12)

hh

01

Hour (1-23)

H

1

Hour (01-23)

HH

01

Minute

m

1

Minute (00)

mm

01

Second

s

1

Second (00)

ss

01

AM/PM

a [*]

AM

Time Zone

zzzz

Pacific Daylight Time [**]

Time Zone (Short)

z

PDT

Day

Number

d

1

Number (01)

dd

01

Name

EEEE

Tuesday

Name (Short)

E

Tue

Month

Number

M

4

Number (01)

MM

04

Name

MMMM

April

Name (Short)

MMM

Apr

Year

Number

yyyy

2007

Number (Short)

y

07

Era

G [***]

AD

Era (Long)

GGGG

Anno Domini

To create a text variable, follow these steps (see Figure 3-38).

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Click the New button. InDesign displays the New Text Variable dialog box. If you had a variable selected when you clicked the New button, the dialog box will be filled in with the default properties of that variable (as though you duplicated it).
  3. Enter a name for the text variable in the Name field.
  4. Select a text variable type from the Type pop-up menu. When you do this, the dialog fills in with the options for that variable type.
  5. Make changes to the options shown in the dialog box to define your new text variable. When the settings look the way you want them to, click the OK button to close the dialog box and return to the Text Variables dialog box.
  6. Click the Done button to close the Text Variables dialog box.

Text variables are stored within the current file. If you want to create a text variable that is available in all new documents, define it when no documents are open. When you do this, the variable will appear in each new document you open.

Editing a Text Variable

You can change the definition of a text variable at any time. When you edit a text variable, all of the text variable instances of that variable will update to reflect the changes you’ve made. If your variable instances are inside paragraphs, be prepared for text to reflow and line endings of composed text to change when you edit a variable.

To change the definition of a text variable, follow these steps.

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Select a text variable and click the Edit button. InDesign opens the Edit Text Variable dialog box.
  3. Make changes in the Edit Text Variable dialog box. When the settings look the way you want them to, click the OK button to close the dialog box and return to the Text Variables dialog box.
  4. Click the Done button to close the Text Variables dialog box.

At this juncture, we are obligated to point out that you can modify any of the built-in text variable instances. You could, for example, change the Chapter Number instance to enter the creation date, as Ole accidentally did when he first tried to create a new text variable. We urge you not to do this.

Loading Text Variables

To load text variables from another document, follow these steps (see Figure 3-39).

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Click the Load button in the Text Variables dialog box. InDesign displays the Open A File dialog box.
  3. Locate and select an InDesign document, then click the Open button. InDesign imports the text variables from the selected document into the current document.
  4. InDesign will display the Load Text Variables dialog box, which shows a list of the incoming text variables. If the document you’ve selected contains text variables with the same name as text variables in the current document, you can choose whether to override the definitions of the existing text variables or to leave then unchanged (by renaming the incoming variable). Click the OK button once you’ve finished, and InDesign will import the text variables from the selected document.

As usual, if the definition of any text variable used in your text has changed, check for text reflow.

Deleting a Text Variable

To delete a text variable, follow these steps (see Figure 3-40). Note that you can use this process to merge two text variables.

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Select the text variable you want to delete and click the Delete button. If the variable has been used in the document, InDesign displays the Delete Text Variables dialog box.
  3. If you want to replace the text variable with another text variable, select the replacement variable from the Existing Variable pop-up menu. To convert all instances of the text variable to text, select the Text option. To delete all of the text variable instances linked to the selected text variable, select the Nothing option.
  4. Click OK to close the dialog box. InDesign applies the changes you’ve specified.

You can delete an individual text variable instance as you would delete any other text: Select it and press Delete.

Converting Text Variable Instances to Text

You can, at any time, convert text variable instances to normal text, in effect “freezing” them in their current state. Of course, if the variable instance is inside a paragraph, this will often cause text to reflow, as InDesign is now free to apply its normal text composition rules to the text of the variable. You can choose to convert individual text variable instances to text, or you can convert all of the text variable instances associated with a text variable to text.

To convert an individual text variable instance to text, follow these steps (see Figure 3-41).

  1. Select the text variable instance with the Type tool.
  2. Choose Convert Variable to Text from the Context menu (or from the Text Variables submenu of the Type menu). InDesign converts the text variable instance to normal text.

To convert all instances of a text variable to text, follow these steps. Note that this does not delete the text variable itself.

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Select a text variable and click the Convert to Text button. InDesign converts all instances of the text variable to normal text.
  3. Click OK to close the Text Variables dialog box.

Again, we have to point out that this may cause text recomposition and reflow. Make certain that the line breaks in the document are where they should be after converting the text variable.

You can also use find and change to work with text variable instances—see the section on finding and changing text, later in this chapter, for more information.

Text Variable Examples

In the following sections, we’ll present a series of “recipes” that show you how to use text variables for a variety of common page layout tasks.

Creating a Time and Date Stamp

We often like to enter the date and time a file was printed, but we can’t always use the built-in time and date stamp from the Print dialog (because the page size is the same as the printer paper size). In the past, Ole has created custom printer’s marks files that move the page information up onto the page, but text variables have rendered that bit of esoteric knowledge obsolete. Note, however, that if you plan to omit the time and date stamp from your final printed version, you’ll need to make arrangements to suppress the printing of the text variables (such as moving them to a non-printing layer).

To create a text variable that will print the time and date a file was printed, follow these steps.

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Click the New button.
  3. Enter a name for the variable and choose Output Date from the Type pop-up menu.
  4. Enter the placeholders and any punctuation or spacing for the date format in the Date Format Field. We use “EEEE, d MMMM, yyyy h:mm a zzzz”—not only does it print the date and time in a civilized format, but it’s fun to say aloud.
  5. Click OK to close the dialog box, then click Done to close the Text Variables dialog box.

Simple Custom Text

Many people, on first hearing about custom text variables, immediately think that they’d be a good way to enter commonly-used text. Don’t do that. There are many other, better ways to accomplish the same end (for example, you can trick autocorrect into entering text for you, as shown in the section on the autocorrect feature, later in this chapter).

Instead, think of custom text variables as a way to enter short pieces of text which might change before your layout is finished. To do this, follow these steps (see Figure 3-42).

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Click the New button.
  3. Enter a name for the variable and choose Custom Text from the Type pop-up menu.
  4. Enter the text you want to have appear when you insert the text variable.
  5. Click OK to close the dialog box, then click Done to close the Text Variables dialog box.

Page X of Y

Ever wonder why so many financial and legal documents use a page numbering scheme that tells you how many pages there are in the document? For some documents, the simple knowledge that there is an end is required to maintain one’s sanity.

If, for whatever reason, you need to extend this sort of reassurance to the reader, it’s easy to do using text variables. There’s nothing to it, really—just enter an automatic page number special character, the text “to,” and insert the predefined Last Page Number text variable (see Figure 3-43).

Why didn’t we enter the “to” as part of the text variable? It’s because we’re following a general rule of keeping text inserted by text variables to a minimum to avoid potential composition problems. No, you can’t specify the last page of a multi-document book.

Running Headers

Many documents feature a layout in which the text of key paragraphs—usually, headings of a given level—appears in the header or footer of each page. Note that this text could also appear in a footer, in a tab on the side of the page, or, really, anywhere on the page. There’s nothing special about the text variable type that limits its use to text frames at the top of the page. That said, InDesign refers to this text variable type as a “header,” so we will, too.

To do this, you create a text variable, then insert that text variable in text on the page or on a master page. Follow these steps (see Figure 3-44).

  1. Choose Define from the Text Variables submenu of the Type menu. InDesign displays the Text Variables dialog box.
  2. Click the New button.
  3. Enter a name for the variable and choose Running Header (Paragraph Style) or Running Header (Character Style) from the Type pop-up menu.
  4. Select the style you want to use from the Style pop-up menu.
  5. Choose Last on Page or First on Page from the Use pop-up menu.
  6. Set up the controls in the Options section of the dialog box as necessary. For example, you’ll almost always want to turn on the Delete End Punctuation option.
  7. Click OK to close the dialog box, then click Done to close the Text Variables dialog box.
  8. Insert the text variable in text using the Insert Variable submenu of the Context menu.

In some layouts, you might need to create a pair of text variables. In a dictionary-style layout, for example, the left hand page header usually contains the first instance of text in a given style on the page, while the right hand page contains the last instance of the style (see Figure 3-45). If the right hand page is the first page in a section, however, it typically uses the first instance of the specified style (not the last, as would normally be the case for a right hand page). You can change the header of the page manually, or you can create a special master page to accomplish the same task.

When a page does not contain text formatted with the specified style, the variable in the header repeats the text from the previous instance of the same text variable. However, InDesign will not carry over the last instance of a given style when another instance of the same style appears on the page (see Figure 3-46). If this is the style of running heading your document calls for, you may have to adjust some pages manually.

Phone book Style Running Header

Another use for a running header is to show the range of a certain type of paragraph style on a given page. In a telephone directory or dictionary, for example, the page headers will show you the alphabetical range of names or topics shown on the page. Ole, for example, proudly shares a phone book page containing family names from “Kustyukov” to “Kwok”.

To set up this type of running header, you’ll need to create two text variables: one for the first instance of a given paragraph or character style on a page, another for the last instance of the same style. Then you create a page header that contains instances of both text variables, as shown in Figure 3-47.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email ask@peachpit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.peachpit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020