A text variable is an item you insert in your document that varies according to the context. For example, the Last Page Number variable displays the page number of the last page of the document. If you add or remove pages, the variable is updated accordingly.
InDesign includes several preset text variables that you can insert in your document. You can edit the format of these variables, or you can create your own. Some variables, such as Running Header and Chapter Number, are especially useful for adding to master pages to ensure consistent formatting and numbering. Other variables, such as Creation Date and File Name, are useful for adding to the slug area for printing.
The options available for creating the variable depend on the type of variable you specify. For example, if you choose the Chapter Number type, you can specify text to appear both before and after the number, and you can specify the numbering style. You can create several different variables based on the same variable type. For example, you can create one variable that displays “Chapter 1” and another that displays “Ch. 1.”
Similarly, if you choose the Running Header type, you can specify which style is used as the basis for the header, and you can select options for deleting end punctuation and changing the case.
A variable created with the Chapter Number type inserts the chapter number. You can insert text before or after the chapter number, and you can specify a numbering style.
If the document’s chapter number is set to continue from the previous document in the book, you may need to update the book’s numbering in order for the appropriate chapter number to appear.
Creation Date inserts the date or time the document is first saved; Modification Date inserts the date or time the document was last saved to disk; Output Date inserts the date or time the document starts a print job, exports to PDF, or packages the document. You can insert text before and after the date, and you can modify the date format for all date variables.
Date variables use the language applied to text. For example, the creation date may appear in Spanish text as “01 diciembre 2007” and in German as “01 Dezember 2007.”
Abbreviation |
Description |
Example |
---|---|---|
M |
Month number, no leading zero |
8 |
MM |
Month number, leading zero |
08 |
MMM |
Abbreviated month name |
Aug |
MMMM |
Full month name |
August |
d |
Day number, no leading zero |
5 |
dd |
Day number, leading zero |
05 |
E |
Weekday name, abbreviated |
Fri |
EEEE |
Full weekday name |
Friday |
yy or YY |
Year number, last two digits |
07 |
y or YYYY |
Full year number |
2007 |
G or GGGG |
Era, abbreviated or expanded |
AD or Anno Domini |
h |
Hour, no leading zero |
4 |
hh |
Hour, leading zero |
04 |
H |
Hour, no leading zero, 24‑hour format |
16 |
HH |
Hour, leading zero, 24‑hour format |
16 |
m |
Minute, no leading zero |
7 |
mm |
Minute leading zero |
07 |
s |
second, no leading zero |
7 |
ss |
second, leading zero |
07 |
a |
AM or PM, two characters |
PM |
z or zzzz |
Time zone, abbreviated or expanded |
PST or Pacific Standard Time |
This variable inserts the name of the current file into the document. It’s commonly added to the slug area of the document for printing or used in headers and footers. In addition to Text Before and Text After, you can choose the following options.
The File Name variable is updated whenever you save the file with a new name or to a new location. The path or extension does not appear in the document until it’s saved.
The Last Page Number type is useful for adding the total number of pages in a document to headers and footers using the common “Page 3 of 12” format. In this case, the number 12 is generated by the Last Page Number, and it’s updated whenever pages are added or removed. You can insert text before or after the last page number, and you can specify a numbering style. From the Scope menu, choose an option to determine whether the last page number in the section or document is used.
Note that the Last Page Number variable does not count the pages in the document.
By default, the Running Headers variables insert the first or last occurrence (on the page) of the text to which the specified style is applied. See Create variables for running headers and footers for a description of Running Header variable options.
This variable is commonly used for inserting placeholder text, or a text string that may need to be changed quickly. For example, if you’re working on a project that uses a code name for a company, you can create a custom text variable for the code name. When you are able to use the real company name, you can simply change the variable to update all the occurrences.
To insert special characters in a text variable, click the triangle to the right of the text box.