## Advanced authoring in Microsoft Word – Part 18: Automatic numbering of equations

In a previous post we noticed that Microsoft Word has no built-in automatic way of numbering equations. Indeed, it is not even typographically possible to put any text next to a display equation! In that post, I described the standard workaround which enables you to produce the same visual appearance as if a display equation is on the same line as some other text. Using that technique, you can manually number your equations.

However, it takes quite some time to setup the construction, and the numbering is still manual, and there is no way to make cross-references to the equation. In this post, we will solve all three of these problems.

Problem 1. First, is there a simpler way to insert the 1×3 table in the construction? Of course, you could use copy-paste, but there is a more convenient way using ‘Building Blocks’. To set this up, create the construction once and for all, using an empty formula and a placeholder number (following the seven steps in the previous post) and select the entire table.

Then press Alt+F3 to create a new ‘Building Block’ from the selection.

Give the Building Block the name numeq (say) and press OK.

Now you only have to type numeq followed by F3 (on an empty paragraph) to insert the entire table construction at the caret, after which you only need to enter your equation and its number. You never have to follow the seven steps again!

Warning! You may also press Enter instead of F3 if Word suggests this. If I do this, it works fine, but when I insert the first character of the paragraph after the equation, Word automatically inserts a space character before the desired character. For example, if I press W, Word inserts  w, that is, a space character followed by ‘w’. You must manually remove this unwanted space character. Or stick to F3.

Problem 2. Still, we do the actual numbering manually, which – of course – gets extremely difficulty in long documents (unless you never revise sections you have already written). Fortunately, it is possible to let Word number equations automatically, like headings and figure and table captions.

There are two fundamentally different approaches. The first is to use multi-level lists, like we did for headings. However, for a number of reasons, I do not like that approach. For one thing, I do not believe the method is robust and it is also very difficult (if not impossible) to extend to theorem numbering (as we will describe in the next article in the series).

Instead, I will use a method based on fields and bookmarks (more like figure and table captions). Indeed, Word has a SEQ field which can be used to create sequences of numbered items in the text. To implement this, we need to redo the construction in the building block. So, insert the standard 1×3 table template, as before. But this time we insert a SEQ field in the right-most column. To do this, put the caret in the empty cell and insert brackets (). Now, place the caret between these and press Ctrl+F9. Then write SEQ Equation and press F9. Then select the table and save it as a building block as before (you may overwrite the ‘numeq’ template).

Now you have automatic equation numbering! When you insert the building block (by typing numeq followed by F3 on a new line), you get a new display equation with an automatic number to the right. This number will be updated automatically by Word. For instance, if you insert a new equation before the fifth one, it will become the sixth one.

Well, actually, fields are not updated really ‘automatically’, but almost. They are updated (for example) when you print the document, and you can always update a particular field manually by pressing F9 when the caret is inside it. To update all the fields in the document at once, select the entire text (using Ctrl+A) and press F9.

You can even make Word restart the numbering at the beginning of each new chapter (Heading 1) by using the field SEQ Equation \s 1 instead. More generally, the \s N option tells Word to restart numbering after each Heading N.

Problem 3. So, is there a way to make automatic cross-references to equations? Yes, there is! To allow cross-references to some particular equation, you must give it a bookmark. Although Word can do this automatically, you might want to do it manually, so you can give it a more descriptive name. To do this, select the equation number (not including the parentheses) and press the Bookmark button in the Links group in the Insert tab of the ribbon. Give the equation a document-unique descriptive name and press Add.

Now you can create cross-references to the equation using the ordinary cross-reference window.

If you choose ‘Bookmark text’ as the reference, the equation number will be displayed, but you can also choose the page number, as usual. Of course, the cross-references will be updated ‘automatically’ if the equation number changes, or if it will end up on a new page.

This is awesome!

Show all news items.

Only show the most recent news items.