How cross-reference fields in Word work

Below, you will find general information about how cross-reference fields in Word work. The information applies to both cross-references you insert using Word's built-in functionality and using the add-in DocTools CrossReferenceManager.

The DocTools CrossReferenceManager add-in makes easier and faster to work with cross-references in Word than using the built-in functionality. However,  cross-references you have inserted in a document using DocTools CrossReferenceManager work precisely as if they had been inserted using Word's built-in functionality.

What is a cross-reference in Word?

A cross-reference in Word is a field, i.e. set of codes that instructs Word to automatically insert material into a document. The material inserted by cross-reference fields can be text, section numbers, paragraph numbers, caption numbers, caption labels, etc. The field code can also include special information (referred to as switches) that make the field act or look in a special way, e.g. the field may function as a hyperlink.

There are three types of cross-reference fields in Word:
REF, PAGEREF and NOTEREF

Below, you can read about how the three types of cross-references work.

Type of field

Description

PAGEREF

A cross-reference field that directly or relatively refers to the page on which the target is found is of the type PAGEREF. When you select “Page number” as the “Reference to insert” in the built-in Cross-reference dialog box in Word or in the Insert Cross-reference dialog box in DocTools CrossReferenceManager, the inserted cross-reference field will be of the type PAGEREF. Also, the custom text placeholders {P} and {P_a/b} that can be used in DocTools CrossReferenceManager will insert PAGEREF fields.

NOTEREF

A cross-reference field with a footnote or an endnote as the target will be of the type NOTEREF.

REF

All other cross-reference fields will be of the type REF.

The field code inside a cross-reference field refers to a bookmark that points out the target

A bookmark in Word is a named location or a named block of text or other content in a document.

The field code inside a cross-reference field includes a reference to a bookmark that acts as the target of the cross-reference. See the illustration below.

If you use the built-in functionality in Word for inserting e.g. a cross-reference to a heading, Word automatically adds a bookmark around the heading text, excluding the paragraph mark, if such bookmark is not already found. The name of the bookmark is included in the field code of the cross-reference field. Such automatically added bookmarks are named _Ref followed by eight or nine digits.

When inserting a cross-reference to a caption, a bookmark will also be used to enclose the part of the caption content that is to be displayed by the cross-reference field. The bookmark will enclose different parts of the caption depending on the kind of caption reference you select (e.g. the entire caption or only the label and number).

Example of cross-reference bookmark name

_Ref123456789

The underscore in start of the bookmark name results in the bookmark being handled as a hidden bookmark in Word. You cannot add hidden bookmarks manually, i.e. the built-in Bookmark dialog box doesn’t let you start a bookmark name with “_”.

Hidden bookmarks remain invisible on the screen even if you turn on display of bookmarks. In the Bookmarks dialog box, you must turn on Hidden bookmarks to have the hidden bookmarks listed in the dialog box.

Note that names of bookmarks added by DocTools CrossReferenceManager follow the same syntax rules as the bookmarks added by the built-in cross-reference functionality.

Cross-reference field in Word showing field result and field code

Above: Example of cross-reference field of the type REF showing the field result and the field code. In this example, the h switch is included which means that the field works as a hyperlink so that you go to the bookmarked target when clicking or Ctrl-clicking the field (depending on your Word settings).

Right: The Bookmark dialog box showing the related _Ref bookmark.

Cross-reference fields in Word - Bookmark dialog box showing REF bookmark

Syntax of the field code in cross-reference fields of the types REF, PAGEREF and NOTEREF

REF field code syntax

The syntax for REF fields is:

{ [REF] Bookmark [\* Format Switch ] [Switches ] }

The format switch and switches parts are optional.

Examples:

Field code examples - REF field

PAGEREF field code syntax

The syntax for PAGEREF fields is:
{ PAGEREF Bookmark [\* Format Switch ] [Switches ]}
The format switch and switches parts are optional.

Examples:

Field code examples - PAGEREF field

NOTEREF field code syntax

The syntax for NOTEREF fields is:
{ NOTEREF Bookmark [\* Format Switch ] [Switches ]}
The format switch and switches parts are optional.

Examples:

Field code examples - NOTEREF field

How to find information about the field switches

In the general help on Word, you can find information about the different types of switches that can be used with specific fields.

The fastest way to find this information is often to search using your preferred browser. You can search for "field codes [TYPE OF FIELD] field" (example: "field codes ref field") or something similar.

Cross-references must be updated to reflect changes in the target

Note that cross-references do not update automatically. If cross-references refer to headings, bookmarks, numbers or other targets that have been changed, you need to update the fields to reflect the changes.

You can update cross-reference manually by selecting all (Ctrl+A) and pressing F9. Cross-references will also be updated when you switch to Print Preview or when you print.