Formatting Cross-references

Home Tutorials My MVP FAQs Useful Links

 

Cross-references are one of Word’s most useful features, but users are often dissatisfied with the way they are formatted. This article will discuss how to force Word to use your preferred formatting. First, however, it will explain what a cross-reference is and how to insert one. If you already know all that, you can jump immediately to the section that interests you.

What is a cross-reference?

You probably know in general what a cross-reference is. Whenever you write, “see page 15” or “in Chapter 5” or “in the Further Developments section,” you are using a cross-reference.

If you insert such cross-references as ordinary text, you will have to update them manually if pagination changes or Chapter 5 becomes Chapter 6 or you change the heading “Further Developments” to “Later Developments.” Word, however, provides a way to insert a cross-reference so that it can be updated semi-automatically when the target changes.

How to insert a cross-reference?

In all versions of Word, you insert a cross-reference using the Cross-reference dialog. How you get there depends on the version:

  • In Word 2007, 2010, and 2013: Display the References tab. In the Captions group, click on the Cross-reference button.

  • In Word 2002 and 2003: On the Insert menu, choose Reference, then Cross-reference…

  • In Word 2000 and earlier: On the Insert menu, choose Cross-reference…

Figure 1. The Cross-reference dialog

As you can see in Figure 1, the dialog offers two dropdowns: “Reference type” and “Insert reference to.” The reference types offered include Numbered item, Heading, Bookmark, Footnote, Endnote, Equation, Figure, and Table, plus any other caption labels you have defined (“My New Caption” in Figure 1). What this means is that you can easily insert a cross-reference to any paragraph formatted with one of Word’s built-in heading styles, any paragraph that has been numbered using Word’s Numbering feature, or any footnote, endnote, or caption. This is possible because Word creates built-in “bookmarks” for these items. You can also insert a cross-reference to any other text (or the number of the page on which that text appears) if you first insert a bookmark around or in that text using Insert | Bookmark (Insert | Links | Bookmark in Word 2007 and above). You then select Bookmark as the reference type.

When you select a specific reference type, the box below will be populated with a list of the available choices. You will be asked to specify “For which heading” or “For which numbered item” or “For which bookmark,” choosing from among those listed.

Each reference type offers different options for “Insert reference to.” In most cases, these include the bookmarked text itself and the number of the page on which it appears, along with the paragraph number if the paragraph is numbered. If you select each of the reference types in turn and inspect the “Insert reference to” dropdown, you will see the various options.

The Cross-reference dialog also includes a check box for “Insert as hyperlink.” If you check this box, your cross-reference will be hyperlinked to the referenced item, and anyone who is reading your document electronically (as opposed to printout on paper) will be able to click (or Ctrl+click) on it and go to the referenced item. There is no reason not to choose this option since the cross-reference will not be formatted as a hyperlink (blue and underlined).

Important Note: Cross-references do not update automatically. You can update them manually by selecting the entire document (Ctrl+A) and pressing F9, or they will be updated when you print or Print Preview.

Important Concepts

At this point it will be useful to introduce some Important Concepts about cross-references.

A cross-reference is a field.

Word’s Help defines field as “A set of codes that instructs Microsoft Word to insert text, graphics, page numbers, and other material into a document automatically. For example, the DATE field inserts the current date.” The field inserted by the Cross-reference dialog may be a REF field or a PAGEREF field (if “Page number” has been selected under “Insert reference to”) or a NOTEREF field (if the cross-reference is to the number of a footnote or endnote).

Fields have two appearances.

What you normally see in a document is the result of a field. For example, if you insert a DATE field, you see the current date. If you insert a PAGE field, you see the page number. This result, however, is achieved by a field code. You can see this field code by “toggling” the display. The easiest way to do this is to press Shift+F9 for a single field or Alt+F9 for all the fields in a document. These are the equivalent of right-clicking in a field code and choosing “Toggle Field Codes” or checking/clearing the checkbox for field codes on the View tab of Tools | Options (in Word 2007, this is Office Button | Word Options | Advanced: Show document content: Show field codes instead of their values).

Fields can be modified with switches.

When you view a field code, you will often see text after the name of the field. For example, in a DATE field, you might see something like \@ "MMMM d, yyyy". In many Word fields you will also see \* MERGEFORMAT. The text that follows backslashes in a field is a “switch.” Word’s Help doesn’t define a field switch, but perhaps it will help to think of it as analogous to a railroad switch, which directs a train to one track or another. The field switch tells Word something about how to present the value that results from the field. The “date-time picture” switch quoted above tells Word to present the date as, say, “September 18, 2009” instead of 9/18/09 or 18 September 2009 or any other date format (see my article on date fields for more).

If you checked the box for “Insert as hyperlink” in the Cross-reference dialog, you will see the \h switch in your REF or PAGEREF or NOTEREF field code.

Fields can be edited by the user.

Many of the dialogs that make it easy to insert fields in Word (not just the Cross-reference dialog but also others that insert index entry fields, date fields, page numbers, and so on, as well as the Insert | Field dialog itself) often have dropdown lists or check boxes that allow you to choose certain formatting options, but sometimes the only way to achieve the effect you want is to edit the field directly by displaying the field code and typing in text manually. This includes adding switches to control the appearance of the field (for examples, see my article on TOC switches).

Fields can be formatted.

You can apply formatting to fields. Sometimes that formatting is wiped out when you update the field. Below I will describe some ways to ensure that fields retain the formatting you prefer.

Fields can be found with Find and formatted with Replace.

Some of the techniques described below rely on searching for fields using Word’s Find dialog. You can search for any field by using the code ^d or ^19 followed by a space and the field name. For this to work, however, you must have field codes displayed (use Alt+F9 to toggle the display).

Formatting NOTEREF fields

If you insert a cross-reference such as “see footnote 22,” you ordinarily want the number to be formatted like the surrounding text. But sometimes you use a cross-reference to a footnote or endnote number to stand in for a footnote/endnote reference mark. For example, you have inserted footnote 22, and now you want to refer to that same footnote again. The footnote reference mark is (by default) superscript, and so you want the cross-reference to be superscript as well.

Fortunately, this is one of the easiest formatting tasks. When you insert the cross-reference, instead of choosing “Footnote number” or “Endnote number,” select “Footnote number (formatted)” or “Endnote number (formatted).” This will add the \f switch to the NOTEREF field.

If you belatedly discover that you have omitted to make the correct choice, you can manually edit the NOTEREF field in either of two ways. You can press Alt+F9 to display the field code and manually type in the \f switch, then Alt+F9 to toggle back (and F9 to update the field). Or you can right-click on the field, choose Edit Field, and check the box for “Insert reference mark.”

Important Note: What the \f switch does (in effect) is apply the Footnote Reference or Endnote Reference style. So if you have modified the style to be, say, bold and not superscript, then your cross-reference will also be bold and not superscript; it will be formatted just the same as the footnote or endnote reference mark that is used when you insert a footnote or endnote.

Change the case of a cross-reference

Suppose you have inserted a cross-reference to Figure 1 or Chapter 5, but the style you are following requires your cross-reference to say “figure 1” or “chapter 5.” You can achieve this by using a format (\*) switch. Word’s Help describes these switches for capitalization formats, number formats, and character formats in the Help topic “Format (\*) field switch.” What we want here are the capitalization switches, which Help lists as follows, with a description of what each one capitalizes:

\* Caps
The first letter of each word. For example, { FILLIN "Type your name:" \* Caps } displays “Julie Tanner” even if the name is typed in lowercase letters.

\* FirstCap
The first letter of the first word. For example, { COMMENTS \* FirstCap } displays “Weekly report on sales”.

\* Upper
All letters. For example, { QUOTE "word" \* Upper } displays “WORD”.

\* Lower
None of the result; all letters are lowercase. For example, { FILENAME \* Lower } displays “weekly sales report.doc”.

If the referenced information is typed in all caps, you may need to add the \* Lower switch followed by \* Caps or \* FirstCap as desired.

Again, there are two ways to add one of these switches to your REF field. You can display the field code and manually type in the switch. Or you can right-click, choose Edit Field, and choose an option from the Format dropdown (where they are listed as Uppercase, Lowercase, First capital, and Title case).

Change the font formatting of a cross-reference

There are two format switches that can be added to fields that affect font formatting. The \* MERGEFORMAT switch is applied to field results (the text displayed by the field), and the \* Charformat switch is applied to the field itself.

There are various reasons why you might want to apply direct font formatting to a REF field. For example, the Caption style by default is formatted as bold. But if you think that is ugly, you may have modified the style to be not bold, but perhaps you have applied bold formatting to just the caption number, so that you have something like this:

Figure 1. This is the first caption.

If you cross-reference the figure number, you will get “See Figure 1.” You can remove the bold formatting, but every time the field is updated, the bold will return. Fortunately, you can override this behavior with one of the format switches.

The \* MERGEFORMAT switch (not recommended)

The \* MERGEFORMAT switch is added by default to many fields that you insert in Word (unless you enter them yourself manually by pressing Ctrl+F9 and typing the field syntax). The switch is represented in some field dialogs by a check box labeled “Preserve formatting during updates.” This means that you can apply, say, bold formatting to a DATE field, and, even if the date changes, the text in the document will remain bold.

As it happens, the \* MERGEFORMAT switch is not included by default in cross-references, but there are times when it might be useful, and there are times when it appears automatically. When you apply formatting to any other field, the field result displays the formatting and retains it through updates. If you apply formatting to a REF field, however, Word automatically adds a \* MERGEFORMAT switch to the field. This may or may not be what you want (if you don’t want it, note that the Undo list will include “Automatic Change,” which you can Undo).

The advantage to using this switch is that it allows you to apply formatting to just a portion of the field. For example, suppose you have a heading reading “This is a heading.” In your cross-reference, you want to italicize “heading” so that it reads “This is a heading.” If you add \* MERGEFORMAT, Word will preserve this formatting through updates.

The catch is that Word applies the formatting very literally. You have italicized the fourth word of the heading. If the heading changes to, say, “This is a different heading,” then your cross-reference will read “This is a different heading.”

On the other hand, suppose you have cross-referenced an entire figure caption, including the label and number along with the caption text. You want the figure label and number to be bold and the caption text italic. You can apply this formatting to the cross-reference text, add a \* MERGEFORMAT switch, and hope for the best. Provided the caption does not become longer, you will be home free. For example, if the caption is “Figure 1. This is a figure,” then your cross-reference will say, “Figure 1. This is a figure.” If the figure number changes, you’re still okay. But if you add the word different, you will get “Figure 1. This is a different figure.”

To achieve the desired result unbreakably, you would need to insert two cross-references, one to “Only label and number” and one to “Only caption text” and format them individually (and for that you might as well use the \* Charformat switch.

As you can see, there are good and sufficient reasons why \* MERGEFORMAT is not recommended for REF fields. Another of these is that, if a user-defined bookmark is inadvertently deleted, the REF field will display “Error! Reference source not found,” and this error message will be formatted as bold. Even if you correct the error by restoring the bookmark, the updated field will remain bold. A better solution for formatting, then, is the \* Charformat switch.

The \* Charformat switch (recommended)

Word’s Help describes this switch as follows:

\*Charformat
Applies the formatting of the first letter of the field type to the entire result. The result of the following example has bold formatting because the “R” in “REF” is bold.

{ REF chapter2_title \* Charformat } displays “Whales of the Pacific”.

Although it suffices to format just the first letter of the field code, it works just as well to apply the desired formatting to the entire field (which is what we will later do with the Replace dialog).

Since the behavior of the \* MERGEFORMAT switch is so quirky and the behavior of the \* Charformat switch so reliable (albeit limited), it is hard to see why Word seems so bent on adding the \* MERGEFORMAT switch instead. If for any reason you find that \* MERGEFORMAT is not giving the results you want, you will be well advised to try using a \* Charformat switch instead.

Formatting hyperlinked cross-references

We said above that hyperlinked cross-references do not display the Hyperlink character style (blue and underlined). Even if you manually apply the Hyperlink style, the cross-reference will still not be blue and underlined (Word can be very stubborn sometimes). You can, however, apply blue font color and underlining as direct font formatting and add the \* MERGEFORMAT or \* Charformat switch, and the cross-reference will remain blue and underlined even after being updated.

A better approach than direct formatting, however, is to apply a character style. If you don’t know how to create a character style, see the instructions in my article on the StyleRef field. Note that this doesn’t have to be blue and underlined; you can use any formatting you choose to signal to readers that the marked words are a hyperlink. For example, one user wanted to distinguish them with a pale yellow highlight; this can be achieved with a character style that applies yellow shading to the text. The advantage to a style in this latter case is that text shading cannot be applied using Find and Replace (though you can apply a Highlight that way).

Changing the formatting of multiple cross-references

Now we come to the nitty-gritty of this article. Suppose you have already inserted dozens (perhaps hundreds) of cross-references that are not formatted the way you want them, and you want to change them. Fortunately, this is possible using Find and Replace.

Applying formatting to all REF fields

As mentioned above, fields can be found and formatted using Word’s Replace dialog. The code for an opening field brace is ^d or (if you are using wildcards) ^19. So if you search for ^19 REF, Word will find every REF field in the document. If you type that string in the “Find what” box, you can then leave the “Replace with” box empty and simply apply formatting. To do this:

  1. Press Alt+F9 to display field codes (so that Word can see REF in the fields).

  2. Press Ctrl+H to open the Replace dialog.

  3. In the “Find what” box, type
    ^19 REF

  4. Click More to expand the dialog.

  5. Important: Make sure the insertion point is in the "Replace with" box (even if you placed it there before clicking More, it will have reverted to the "Find what" dialog).

  6. Click Format, then Font or Style.

  7. Select the desired font formatting (such as blue and underlined) or the character style you created, and click OK.

  8. Beneath the “Replace with” box, you should see “Format: Underline, Font color: Blue” (or whatever formatting you chose) as shown in Figure 2, or “Format: Style: Your Style Name” (as shown in Figures 3 and 4).

  9. Click Replace All.

  10. Press Alt+F9 to toggle the display back to field results.

  11. Press Ctrl+A, then F9 to update fields. You should see all your cross-references with the formatting you chose.

Figure 2. The Find and Replace dialog showing the correct entries to format REF fields

Applying formatting only to hyperlinked cross-references

The procedure above will format all cross-references. But perhaps you have some that are hyperlinked and some that are not, and you want to format only the hyperlinked ones. This is also easy to do, because the hyperlinking is indicated in the REF field by the \h switch.

To format only hyperlinked REF fields, use the steps listed above with two modifications:

  1. In the “Find what” box, use this string:
    REF * \\h

  2. Check the box for “Use wildcards.”

The wildcard * stands for “0 or More Characters,” so this string will find a REF field with any amount of text between the REF identifier and the \h switch. If you find that Word is selecting more text than a single field, you may want to use Find Next instead of Replace All so that you can verify the placement before clicking Replace.

Important Note: The extra backslash is necessary to “escape” the backslash before h, telling Word to read it literally and not as a wildcard character.

Applying formatting and adding a format switch

As you’ve seen, applying formatting is pretty easy. But if you want to apply the formatting and preserve it from updates, you will want to insert the \* Charformat switch as part of your Replace operation. This, too, can be done. It is relatively simple for hyperlinked REF fields and only a little more complex for ones that are not hyperlinked.

The instructions below will use the same steps outlined above, with just a few changes. You will need the following advance preparation:

  1. As before, make sure that field codes are displayed (press Alt+F9).

  2. Both Replace operations require wildcards, so make sure you have the “Use wildcards” box checked.

  3. Very Important: Because the \* Charformat switch contains reserved characters that can’t be used in the “Replace with” box, you will be inserting it from the Clipboard (using the code ^c), so before you begin the Replace operation, you need to type \* Charformat into your document (or anywhere), select it, and copy it to the Clipboard.

For hyperlinked REF fields

See Figure 3 for illustration.

  1. In the “Find what” box, type
    REF * \\h

  2. In the “Replace with” box, type
    ^& ^c

  3. Use the Format button to add the desired formatting to the “Replace with” box as described above.

  4. Click Replace All. Your cross-references should be formatted, with a \* Charformat switch added.

Figure 3. Find and Replace dialog showing the correct entries to find hyperlinked REF fields, add a \* Charformat switch, and apply formatting

Warning! If your document contains the word “REF” (as this article does), this Replace operation will find much more than just REF fields. When I tested this Replace on this article (having inserted some cross-reference fields at the end for testing purposes), I got very startling results! And be sure to include the space after the word REF so that Word doesn’t find words beginning with those letters.

Important Note: If you find that the search is including more than just a single REF field, you may wish to use Find Next instead of Replace All so that you can verify each insertion before making it.

For non-hyperlinked REF fields

See Figure 4 for illustration. Note that this will find all REF fields, both hyperlinked and non-hyperlinked (with the exclusions noted below).

  1. In the “Find what” box, type
    REF _Ref[0-9]{1,9}

Important Note: If the list separator is not a comma but a semicolon, then {1,9} must be {1;9}.

  1. In the “Replace with” box, type
    ^& ^c

  2. Use the Format button to add the desired formatting to the “Replace with” box as described above.

  3. Click Replace All. Your cross-references should be formatted, with a \* Charformat switch added.

Figure 4. Find and Replace dialog showing correct entries to find non-hyperlinked REF fields, insert a \* Charformat switch, and apply formatting

Important Note: This Replace operation will work only for cross-references to the hidden bookmarks that Word creates for headings, numbered items, footnotes, endnotes, and captions. It will not work for cross-references to user-created bookmarks.

More Information: The string REF _Ref[0-9]{1,9} tells Word to look for a series of up to nine digits following _Ref, which is the format for the bookmarks Word creates. As far as I have been able to determine, they all actually have either eight or nine digits; it has been speculated that the ones with eight have an initial zero suppressed.

This article copyright © 2009, 2011, 2014 by Suzanne S. Barnhill. I am indebted to Word MVPs Lene Fredborg, Jay Freedman, Graham Mayor, and Tony Jollans, who contributed helpful suggestions.