Separate table (or figure) numbering for appendices

A question recently came up in the Word-PC e-mail list which is quite typical of something a student doing a thesis or dissertation might come across. I will also modify this post to that context. I was quick to give an answer, and only later thought through all the implications, so that my initial answer would have been less than satisfactory. Here is, what I believe, a more robust solution.

The requirement is as follows:

  1. A dissertation is using chapter-based numbering instead of sequential numbering for its tables (i.e., in Chapter 3, the tables would be 3-1, 3-2, etc.). Note of course, that the student can set the delimiter (here a hyphen) in the process of activating chapter based numbering (the dialog is shown below)—many students use a period.
  2. The dissertation also has appendices, which must be numbered with uppercase letters (Appendix A, Appendix B, etc.).
  3. Those appendices contain tables (or figures, or any other label created with the Insert Caption tool).
  4. Those tables need to be numbered in the chapter-based style, but now reflecting the Appendix number. Thus A-1, A-2, etc. for Appendix A, and so on.

Parts of these are very easy to do. It’s the combination that is a headache.

Requirement 1 is simple. Just use the Insert Caption tool to add the numbers, and set the table-based numbering. See p. 162–163 of Doing your dissertation with Microsoft Word if you have the book (if you don’t some screen caps below will help).

Requirement 2 is equally simple. I have created, in the two templates (Thesis 2010.dotx and Thesis up 2009.dotx) which can be downloaded from the examples page, a style called “Appendix Title” that uses normal upper case alphabetic numbering. This is what the style looks like, showing its definition:

Some pointers. When modifying the style, be sure to go to the paragraph dialog and set its outline level to Level 1. This will ensure that it should be included in your Table of Contents (mine is based on Heading 1, which gives the same end result). Using this style for your appendix headings gives them the desired numbering scheme, thus satisfying requirement 2.

Requirements 3 and 4 are dealt with together, as these are the more tricky ones.

Here are the problems:

When Word adds caption labels, and those caption labels use chapter-based numbering, Word actually adds two fields: One is a STYLEREF field which is set to automatically pull in the heading level 1. The second is a SEQ field, which is set to restart after each occurrence of heading level 1.

Furthermore, whenever you add a table anywhere in the dissertation, Word runs through all instances of the table, and resets all of them. If you thus make changes to the switches of these caption labels in the appendix, they can get nixed by adding any table anywhere else in the dissertation.

To get started, use the Insert Caption tool to insert the caption label for the first table in the first appendix. We will modify the fields it adds afterwards (or, if you are confident writing out fields by hand, you can just skip ahead).

Click on Insert Caption (Captions group, References ribbon). From the Caption dialog, choose Numbering… to open the Caption Numbering dialog, and include the chapter number, also choosing the delimiter (separator). No need to change the Chapter start with style setting here, since all that is allow are the nine built-in heading levels. We will modify this manually later:

Once the chapter-based numbering has been set, the Caption dialog should look more or less like this:

Clicking on OK let’s Word add the caption label, using two fields.

Let’s first look at those fields Word adds. This is what they look like before and after being selected and set to Show field codes (Shift + F9):

So. The field codes (the bits between the braces) and text Word adds, is:

Table { STYLEREF 1 \s }–{SEQ Table \* ARABIC \s 1}

We can’t just change the STYLEREF field from 1 (Word shorthand for the built-in style “Heading 1”) to “Appendix Title,” as Word will nix this each time it updates the caption labels when a table is added somewhere. We also cannot change the restart switch for the SEQ field to anything other than 1-9 (i.e., Word’s nine built-in heading styles).

So we need a slightly different approach.

The first thing is to keep Word from automatically changing these table captions. The second is to get it to restart with each new appendix. Both of these are accomplished by setting the first appendix table caption to:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \r 1}

The change to the STYLEREF field will pull in the required appendix number (from my custom style–if you are using a different style, then you would have to include whatever that style name would be). But note that it is the change to the SEQ identifier (from Table to AppendixTable) that essentially creates a new sequence, and prevents Word from reverting the STYLEREF field from STYLEREF “Appendix Title” back to STYLEREF 1. The SEQ field switch \r 1 which has replaced the \s 1 switch tells Word to restart at 1 here. Note that the 1s in the two switches have vastly different meanings. The \s 1 means restart numbering if there is an instance of “Heading 1” style between me and the preceding similar caption. The 1 refers to Heading 1. The \r 1 means restart right here, using the number 1. Here the 1 refers to 1.

But still more needs to be done. For each subsequent table in each appendix, the caption must be:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \n}

Here the \n switch just tells Word to continue the numbering sequence from the previous similar caption label.

So the first table caption of each appendix will be:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \r 1}

And the table caption of all other tables in each appendix will be:

Table { STYLEREF “Appendix Title” \s }–{SEQ AppendixTable \* ARABIC \n}

Probably the best way to achieve this is to simply copy and paste the caption paragraph for each new table. Yes, it’s a little manual work, but it’s not that bad. If you’re work averse, you could always record a macro writing out the fields (remember to use Ctrl + F9 to add the field braces) and then run that macro each time. Remember to also set the paragraph style to Caption, thus ensuring consistent formatting for your chapter and appendix tables.

Unfortunately, the job is not quite done.

Because we changed the SEQ field from SEQ Table to SEQ AppendixTable, the tables in the appendices will not appear in the list of tables. So we need to fix that.

To get that done, insert (or re-insert) the list of tables.

From the Table of Figures dialog, select the Options button:

In the Table of Figures Options dialog, specify that the table of figures should be built from the Caption Style:

Once you click on OK, notice that back in the Table of Figures dialog, Word will have set the Caption label to (none). This won’t do, because that means that the table will include, tables, figures, and any other caption labels. Compare the Table of Figures dialog below to the one shown above:

Just reset this to Table, and click on OK:

The end result is a list of tables that includes both your chapter and appendix tables:

The great thing about this approach is that it is stable and it works. It will withstand the updating caused by adding new tables or deleting existing tables, updating all fields in the document, closing and re-opening the document, etc.

It does require a small amount of manual work, but I think it is well worth the effort.

Update (2014-03-11):
If you want to do this with multiple captions (e.g., Tables and Figures in your appendices), then a little more work is needed. Read about it here.

Share

Numbered equations in Word

Microsoft boasts of its academic staff, but really, I often get the impression that no-one involved with Word has any idea of what academics do, need, or want. When the referencing tools in Word came out I got all excited, only to be severely disappointed (you can read about all my gripes in my book). Basically, after more than six years now (from Word 2007 to Word 2013), Microsoft is still more than two decades behind in the reference management field. Then again, is it fair to expect Word to do what is actually the domain of a whole difference class of software? Probably not, but then why did Microsoft even try?

One thing that Word should be able to do, and that you will find people regularly complaining about, is to neatly number equations. It seems that waaaaaaay back (I can’t even recall how far back, but I am certain that it was pre-Word 95), someone at Microsoft thought that being able to add a caption titled “Equation” with the Insert Caption tool was all that any academic would ever want (they probably have never worked through a statistics textbook).

The generally touted workaround (it remains a workaround until Microsoft actually addresses the problem, which seems as likely as Microsoft ever building true 3D capabilities into Excel) is this: Add an unbordered table consisting of one row and three columns, and then add the equation in the middle column, and the number in the right column. See, for example:

http://ist.uwaterloo.ca/ec/equations/equation2007.html

http://blogs.office.com/b/microsoft-word/archive/2006/10/20/equation-numbering.aspx

http://word.tips.net/T000273_Numbering_Equations.html

Here’s my suggested method. I admit that it still requires more manual labour than I feel should be necessary, but I do believe it presents a more robust solution than that presented by Microsoft’s employees. The first step is to add two blank paragraphs, position yourself in the first of these, and then add the equation. Then position yourself to the right of the equation (i.e., just before the first of the two paragraph marks), and press Ctrl + Alt + Enter to add a Style Separator. Now add a tab, and then insert an Equation caption (remembering to set the numbering so as to include the chapter number, and the caption itself so as to Exclude the label from the caption).

Adding an equation caption

The convention, again, is for the equations to be enclosed in parentheses, which can now be added.

This will leave your equations, properly centred on the page, with auto-numbering equation captions properly aligned, that can easily be used to generate a list of equations using the Insert Table of Figures tool.
Admittedly, this may not be an ideal list of equations, as the fact that the actual caption “Equation” is excluded from the caption, means that the list will not contain entries like “Equation 2.1                p.13,” but rather “(2.1)            p.13.”
However, using some bookmark-modification techniques, the parentheses can easily be removed from the reference, and with some creativity, the remaining list can be formatted quite effectively (this need only be done once). Also, very often the idea behind numbering is not to generate a list of the actual equations, but rather to have an auto-numbering list that can be cross-referenced. Because the Caption tool uses the SEQ field, it remains ideal for this purpose. This list will show the equations with the right numbers, in the right order, with the right page references.
By this stage, you should have something similar to this:

Equation separated from caption by Style Separator.

The last thing that needs to be done is to align the equation number. By some quirk, it seems that, while the Style separator does allow you to combine two paragraphs into one, only the first paragraph’s tab stops seem to apply—since Microsoft has totally neglected documenting the Style separator, we are left at a loss as to whether this is by design or by oversight. And yet, if you close and save the file, and re-open it, you may find Word wanting the tab stop for the second “paragraph.” Thus, the safest thing to do seems to be to add the same tab stop on both sides of the Style separator—you need to position the I-beam both to the right and the left of the Style separator, and then add a right tab stop (remember that the Tabs dialog can easily be opened with Alt, O, T) equal to the text width of your page (e.g., if the ruler width is 16 cm, then add a 16cm right tab stop), as is demonstrated below:

Adding a tab stop to align an equation caption

The end result should be something like this:

A properly aligned equation caption

 Of course, all that work can get quite tedious, which is why I have created a simple macro to automate the work for you. You could add this yourself, or you could install my Word uTIlities, which includes this macro where it can be run with a click on the ribbon.

Sub AddCaptionedEquation()
'Created by J. Raubenheimer, 2012
'Adds an empty equation box and a right-aligned equation caption
  With Selection
    .TypeParagraph
    .TypeParagraph
    .MoveUp Unit:=wdLine, Count:=2
    .OMaths.Add .Range
    .MoveRight Unit:=wdCharacter, Count:=1
    .InsertStyleSeparator
    .TypeText Text:=vbTab
    .TypeText Text:="("
    .InsertCaption Label:="Equation", ExcludeLabel:=1
    .TypeText Text:=")"
    .HomeKey Unit:=wdLine
    Dim intPos As Integer
    With .PageSetup
      intPos = .PageWidth - .LeftMargin _
      - .RightMargin - .Gutter
    End With
    .ParagraphFormat.TabStops.Add Position:=intPos, _
     Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
    .HomeKey unit:=wdLine
    .ParagraphFormat.TabStops.Add Position:=intPos, _
     Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
  End With
End Sub
 
Please note, though, that this macro must only be run in a document which already uses the Heading styles to divide and number the chapters.

One last thing about this method needs to be said. Because of the way Word handles cross-references, you will notice that a cross-reference in your text to the equation will include the parenthesis on the left of the equation number. This problem, is caused by the hidden bookmark Word adds around the caption number when you add the cross reference. Again, my uTIlities contain two tools (the Bookmark Manager or the Shrink bookmark tool) that fix this.

After all is said and done, I admit that this approach is still not ideal–the ideal would be a real fix from Microsoft–but it does, to me, present several advantages over other methods, and the fact that I have automated it means that this is not a bad solution to the student who needs numbered equations–it’s what I use.

Share