A variable is a brief, non-formatted piece of content that can be edited in one place but used in many places throughout your project. They're especially good for text that might change frequently, such as version numbers and dates. Variables are stored in variable sets, which can hold multiple variables.
A variable has two main components—the variable name and the variable definition.
An example of a variable name is "CompanyName." The definition for that variable name might be "ACME Incorporated." Using that example, if you were to insert the CompanyName variable into a paragraph of a topic, the phrase "ACME Incorporated" would be added at that spot and shown in the output.
Following are the main categories of variables that you can use.
These are basic variables that you can create in variable sets. They can be used for virtually any purpose (product names, company information, terms that are used frequently). See Creating Variables.
You can create date and time variables based on Microsoft's "Custom Date and Time Format Strings." You can include custom date/time variables in master pages, which is useful for showing when each topic in your output was created. See Creating Custom Date/Time Variables.
You can add a system variable by selecting Insert > Variable. Then select System and choose the specific variable.
The following kinds of system variables are available:
Chapter/Section/Volume Number For Adobe PDF output, you can insert system variables in page layout frames that display your chapter, section, or volume numbers (if you are using autonumbers to identify the various parts of a manual). See Inserting Chapter, Section, and Volume Number Variables into Frames
and About Autonumbers.
- ChapterNumber This displays the current chapter number.
- SectionNumber This displays the current section number.
- VolumeNumber This displays the current volume number.
Date/Time The global format in windows controls the format dates and times in variables.
- LongDate Example: Thursday, December 8, 2017
- LongTime Example: 2:49:00 PM
- ShortDate Example: 12/8/2017
- ShortTime Example: 2:50 PM
Linked Title/Header/File In tables of contents (TOC) and browse sequences, you can insert system variables that are tied to information in the linked topic. These variables ensure that your TOC or browse sequence entries are always in sync with your topic titles, headers, or file names. When one of these variables is used in the TOC or Browse Sequence, the text displays in blue to indicate a system variable is being used (the text will not be blue in the output).
See Creating a TOC and Creating a Browse Sequence.
These variables can be seen in the Variables dialog only if you access the dialog from the Properties dialog for a TOC or browse sequence entry.
- LinkedFile This displays the entry using the name of linked source file, without the file extension.
- LinkedHeader This displays the entry using the name of the first heading in the linked source file.
- LinkedTitle This displays the entry using the title information within the title tag in the linked source file.
Page For print-based outputs, you can use variables to show page number information.
- PageCount This displays the total number of pages in the output.
- PageNumber This displays the current page number in the output.
- SourceFile This displays the name of the file where the variable is inserted.
Title The following types of title system variables are available:
- GlossaryTitle This displays the title of the glossary, if you’ve added one.
- Title This displays the title of the topic.
Note: The LinkedFile and LinkedTitle system variables are different from the Title and SourceFile system variables. While the LinkedFile and LinkedTitle variables show information for the linked source file, the Title and SourceFile variables show information for the file where the variable is inserted. If you use Title or SourceFile in your TOC, you will see the TOC's title or file path in the TOC entry.
You can insert Heading variables into page layouts
In addition to system variables and those you can create (from the "MyVariables" template), you can also add Running Head variables (using the "Running HF" template). A Running Head (or Running HF) variable is a special variable that you can insert into a header or footer in a page layout
Note: Running Head variables are supported only in Microsoft Word output.
When you insert variables into content, there are a few ways to discern that certain content is actually a variable, as opposed to regular text.
First, markers can be turned on or off, providing a visual cue about the content in the form of brackets. When you insert a variable into a topic with markers turned on, the variable definition is displayed in a marker represented by brackets on either side of the definition. If you cannot see all of the information in a marker, you can adjust the marker width. (Click the down arrow next to the Show tags button in the XML Editor. The marker width field is at the bottom of the drop-down menu.)
Here is an example of a variable with markers turned on. (To turn markers on, click the down arrow next to the Show tags button in the XML Editor. Then select Show Markers.)
Here is some more information about variables.
There are usually some initial custom variables (e.g., CompanyName and PhoneNumber) already provided when you start a new project or add a new variable set (using the "MyVariables" template). You can use these variables, modifying their names and/or definitions to meet your needs. You can also create additional variables. A variable set file has an .flvar extension and is stored in the Project Organizer under the Variables folder.
You can also add multiple definitions to a variable, using them as a way to override variables on a target. For example, your company might have multiple phone numbers. You can associate them all with the same variable and use the appropriate one wherever necessary. See Editing Variables.
You can create new variables in the Variable Set Editor. The variables that you create and define in the Variable Set Editor are available to your entire project. However, if you want the definition for a variable to be different in a particular target, you can override the project-level definition for that target in the Target Editor. If you preview a topic, the variable definition associated with the primary target is displayed. See Overriding Variable Definitions in Targets.
You can also override variable definitions only for variables that appear in snippets ("snippet variables"). You can override the snippet variable definition for an entire topic or for a single snippet. When you do this, topic-level variable definitions override project or target variable definitions. Snippet-level variable definitions override topic-level variable definitions. See Overriding Variable Definitions in Snippets.
You can apply a condition tag to a variable so that it is included in some targets but not in other targets.
In addition to inserting variables the "old-fashioned" way, you can also insert variables when using Auto Suggestion (a popup window that predicts content as you type).
You also might hear about CSS variables. These are not the same as the regular variables that are stored in the Project Organizer. Instead, CSS variables are created in a stylesheet. But like regular variables, CSS variables can be used to create information in one place and then re-use it in many places. In the case of CSS variables, you specify a style value once and then insert that variable in any style properties where you want to use it.
Following are the main tasks involved with using variables.
- Add Set You can use the initial variable set provided in a template, but you can add more variable sets if necessary. Each variable set can hold multiple variables. See Adding Variable Sets to Projects.
- Create You can create custom variables within a variable set. See Creating Variables and Creating Custom Date/Time Variables.
- Insert You can insert variables into topics (as well as other elements, such as snippets or page layout frames). See Inserting Variables, Inserting Chapter, Section, and Volume Number Variables into Frames, Inserting Heading Variables Into Frames, and Inserting Running Head Variables into Frames.
- Edit After you create a variable, you can easily edit it in the Variable Set Editor. If you change the definition for a variable that has been inserted into topics, the changes will automatically be reflected in all those topics.
See Editing Variables and Editing Date/Time Variables.
- Update When you create a custom date/time variable, you can set it to update at specific times, such as when you save the file or build the project. Some date/time variables can also be updated manually so they reflect the current date and time.
See Editing Date/Time Variables and Updating Manual Date/Time Variables.
- Pinning Variables You can pin your favorite variables to the top of the list so you can easily find them again later.
See Pinning Variables.
- Variable Groups You can select variables from groups of pinned variables and recently used variables . You can expand or collapse each group. Variable groups are a way to quickly access the variables that you use the most.
See Using Variable Groups.