Custom figure numbering

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Custom figure numbering

Post by Sundog »

I am working in a Word 2007 document that has no section breaks. The document has one appendix, Appendix A. In the body of the document, Figure and Table captions look like this: "Figure 1. FigureTitle" or "Table 1. TableTitle". The author requests that Figure and Table captions in Appendix A look like this: "Figure A.1. FigureTitle" or "Table A.1 TableTitle".

I inserted a section break ahead of the Appendix, which starts with a Heading 1 (Appendix A. AppendixTitle). After the section break, I inserted "A. " Then, below a figure, References > Insert Caption > Numbering > Format: 1,2,3; Include chapter number; Chapter starts with style Heading 1; Use separator . (period) > OK.

Word then tells me that "There is no chapter number to include in the caption or page number. To apply chapter numbers use the Multilevel List button on the Home tab and select a numbering scheme that is linked to the Heading styles."

From there, I need help. Things I try apply to all Heading 1s throughout the document; not what is desired.
Sundog

User avatar
StuartR
Administrator
Posts: 12617
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Custom figure numbering

Post by StuartR »

You can't have a different heading 1 style in one section of the document.
Would you be able to use Figure 1.1, 1.2 etc. in the main document and Figure A.1, A.2 etc. in the appendix?
StuartR


User avatar
stuck
Panoramic Lounger
Posts: 8182
Joined: 25 Jan 2010, 09:09
Location: retirement

Re: Custom figure numbering

Post by stuck »

Can't you just create a new label for the Appendix table & figure captions? I'm at home at the moment and only have Word 97 to hand:
Insert | Caption and click on the New label button
You could then create a new caption style that looks[/i ]like Heading 1 and use that to format the Appendix tables & figures

I have Word 2007 at work and can investigate more tomorrow morning.

Ken

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Ken, that works, but it results in "Figure A. 1" with a space after the "A." Same results if I use "A-" (A hyphen). But Insert Table of Figures won't allow two different figure Labels, so this approach won't work.
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Stuart, I inserted a Section Break before the Appendix. How can I use a Heading 1 in the main body and a different Heading 1 in the Appendix, after the section break? The Author requests not to use Figure 1.1 etc. if it can be avoided.
Sundog

User avatar
StuartR
Administrator
Posts: 12617
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Custom figure numbering

Post by StuartR »

It's not entirely satisfactory, but see if Shauna Kelly's article about appendix numbering helps.

Alternatively you could create your figure captions manually, using a SEQ field. For example.

Figure {SEQ fignum}. Title of a figure in the body of the document
Figure {SEQ fignum}. Title of another figure in the body of the document

Figure A.{appfignum} Title of a figure in the appendix
Figure A.{appfignum} Title of another figure in the appendix

the trouble with this method is that you can't create a table of contents very easily, and adding references would require you to create suitable bookmarks.
StuartR


User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Custom figure numbering

Post by HansV »

Didn't you mean Figure A.{SEQ appfignum} instead of Figure A.{appfignum} ?
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Leave it to Hans to seek out the missing SEQ! :clapping:
Sundog

User avatar
StuartR
Administrator
Posts: 12617
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Custom figure numbering

Post by StuartR »

HansV wrote:Didn't you mean Figure A.{SEQ appfignum} instead of Figure A.{appfignum} ?
Yes, of course, thanks for the correction.
StuartR


User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Stuart, thanks for the Shauna link; interesting, but as you said, not entirely satisfactory.

About all I've found that sort of works is to insert the Appendix figure captions normally, then in the Appendix, search for "Figure " (Figure followed by a space) and replace with "Figure A-" (Figure followed by a space followed by A followed by a hyphen). Then update the Table of Figures. Appendix Figure 18 becomes Figure A-18.

Now if I could only get the numbers in the figure captions to start from 1 in the Appendix, I'd be set.
Sundog

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Custom figure numbering

Post by HansV »

Sundog wrote:Now if I could only get the numbers in the figure captions to start from 1 in the Appendix, I'd be set.
Right-click the first caption number in the appendix.
Select Toggle Field Codes from the popup menu.
You should see something like

{ SEQ Figure \* ARABIC }

Add the switch \s 1 before the closing field brace, so that it looks like

{ SEQ Figure \* ARABIC \s 1 }

Press F9 to hide the field code and to update the field result. The \s switch forces the sequence to restart at the value specified after \s, in this example at 1.
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Excellent clue, Hans. In my Word 2007, \r 1 also works. Then it is necessary to select all and update the fields. That solves the problem completely.

However, if I Ctrl+A in my document to select everything, which has a lot of charts, and hit F9, I get the following error message, and after wearing out my left-clicker, it forces me to nuke Word to get out of it:
You do not have the required permissions to view the files attached to this post.
Sundog

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Custom figure numbering

Post by HansV »

One option would be to select Edit | Links... as the error message suggests, and to break the links to source files that cannot be found. You should be able to update all fields after that.

Another option is to run the following macro; it will update only the SEQ fields and leave all other fields alone:

Code: Select all

Sub UpdateSEQFields()
  Dim fld As Field
  For Each fld In ActiveDocument.Fields
    If fld.Type = wdFieldSequence Then
      fld.Update
    End If
  Next fld
End Sub
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

A workaround that only gives me the Chart link error once: Open the Styles pane, click in an Appendix caption, right-click on the style, and choose Select All nnn Instance(s). THEN hit F9.

I like your macro idea, since the document charts may be linked to who knows how many files.
Sundog

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Macro works great.

To help automate this process, I'm thinking I need a macro that would do the Figure > Figure A. search and replace starting from the Appendix. Since the word "Figure" also appears in the running text, the macro would have to start at the cursor and run to the end of the document, acting only on the word "Figure " that has a certain Style.

So, something along these lines?

Code: Select all

' Changes Figure  to Figure A., from cursor to end of document.

Sub AddAtoFigureCaptions()
    Dim capt As Style
    For Each capt In ActiveDocument.Styles
'       If capt.ParagraphFormat = something Then
'       Replace "Figure " With "Figure A."
        End If
    Next capt
'   Stop when you reach end of document.
End Sub
This needs help, as I am unsure of all the proper VBA to use.
Sundog

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Custom figure numbering

Post by HansV »

Try this version. It uses the Find object to replace all instances of "Figure " formatted with the Caption style with "Figure A." from the current insertion point to the end of the document in one go.

Code: Select all

Sub AddAtoFigureCaptions()
  With Selection.Find
    .Text = "Figure "
    .ClearFormatting
    .Style = ActiveDocument.Styles(wdStyleCaption)
    With .Replacement
      .Text = "Figure A."
      .ClearFormatting
    End With
    .MatchCase = False
    .MatchWildcards = False
    .Forward = True
    .Wrap = wdFindStop
    .Execute Replace:=wdReplaceAll
  End With
End Sub
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Thanks again, Hans. I will try your code today.

Is it the

Code: Select all

.Wrap = wdFindStop
that gets to the end of the document and quits?
Sundog

User avatar
HansV
Administrator
Posts: 78549
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Custom figure numbering

Post by HansV »

Yes, it is. The other options are wdFindContinue (continue searching at the top of the document) and wdFindAsk (display a message box).
Best wishes,
Hans

User avatar
Sundog
5StarLounger
Posts: 704
Joined: 28 Jan 2010, 22:47
Location: Alien Country (Roswell NM)

Re: Custom figure numbering

Post by Sundog »

Thanks for the insight.
Sundog