I spend quite a lot of time creating long documents, usually in Microsoft Word.  One of the things that people often get hung up on is page numbering.  Simple documents are clearly not a problem but when you start to get a bit more fancy, things can get more complex.

A typical document for me has a cover sheet, table of contents (possibly covering more than one page) and other assorted elements and usually don’t want to count these in the total page count and want the numbering to start at page 1 for the document proper and run through to the end.

For this we are going to make sure that Word has Header/Footer already present.  Word has a number of handy auto-text entries and one of these will pop something, usually in the footer, along the lines of;

Page x of y

To do this it uses two built in variables, or what Word calls fields, and what you are seeing is in fact;

Page {PAGE} of {NUMPAGES}

If you highlight the text and either select Toggle Field Settings or just press Alt+F9 you will see the { FIELD NAME } bits. So that all seems fairly simple, {PAGE} is the current page and {NUMPAGES} is the total pages in the document. First job is to get {PAGE} to start when you want it to.

So, first things first, my preference is to create separate Word sections for both the cover and TOC and the a new section of what is now in effect the document proper. By default the Header and Footer will be linked across sections so with this approach you will need to double click the footer on the first page of the “document proper” section and make sure that the “Link to Previous” option in the ribbon is unticked.

This will break the link to sections above but everything that follows will inherit the footer from now on unless you tell it otherwise. Rather than use pure auto-text I tend to use a table to keep the Page, number, of and total nicely lined up but however you do it, once you have the {PAGE} field in place right clicking should give you an option for Format Page Numbers…. This will display the following;

Word Page Numbering Dialog Box

As you can see, I’ve selected Start at 1 rather than continue from previous section.  This means that no matter how many title pages, contents pages or other preliminary material the document will be numbered 1 to x.

So now that the start is correct the only thing left is that currently {NUMPAGES} will be counting all the pages not just the ones in the part of the document you are interested in.

There is a quick fix for simple documents here and that is to simply replace the {NUMPAGES} field with the {SECTIONPAGES} field.

However this will obviously only work if you write the rest of the document in one section and this for long documents probably isn’t ideal, especially as sections are a great way of allowing you to mix portrait and landscape pages in the same document.

So what we need to do is subtract the pages at the front from the total number to get the correct figure.

This is fairly simple but there is a catch. For this example we have a cover page and one page of contents so we need to remove 2 from the total.  Word can calculate fields so in other words { NUMPAGES – number } however, although the fields appear to be surrounded by {} and the correct formula would be {={NUMPAGES}- 2}; if you simply type that it won’t work.

The reason is that the field braces {} are what are called special characters and typing them manually doesn’t tell Word that you mean special braces not ordinary braces.

So, having revealed the fields, select the whole {NUMPAGES} part including the braces and press Ctrl-F9. This will add the correct type of {} around the existing field, i.e. you will now see;

{{NUMPAGES}}

Then simply put your cursor between the first two braces and type =, then move it to between the last two and type -2 so that you have the following:

{ ={NUMPAGES}-1 }

Press Alt-F9 and the fields toggle back to the actual values and your document should now be showing the correct number of pages.

That should be all you need to get things flowing properly.

Shortcuts

Towards the end of the above I mentioned some keyboard shortcuts.  The whole Office suite is littered with them and they can be a time saver if remembered.  When working with fields (which includes much more complex items than page numbers, including things like table of contents) it is handy to remember the following:

  • F9 – Update fields in the current section
  • Ctrl+F9 – Insert field braces when manually entering fields or introducing calculations
  • Shift+F9 – Toggle field codes for fields in the current section
  • Alt+F9 – Toggle field codes for the whole document
  • Ctrl+Shift+F9 – Converts all fields in a section to standard text (which means they won’t then update)