Equation Numbers, inserting field

S

SeanF74

I have a list of equations in a word document that I need to add a reference
(the first equation in the document will be equation A, the second will be
equation B, etc. When I get to equation 27 it needs to be AA, then 28 will
be AB...) next to. However, I will be adding other equations randomly
throughout the document and referring to the equation reference in text
paragraphs. I would like to have both the equation reference and the text
paragraphs to update if I add an equation to the middle of the document. I
know I should use a field code and cross reference it in the text to do this,
but I don't know which one I should use or how to insert it next to the
equation in Word 2007. Could anyone please help?

Thanks,
 
S

Suzanne S. Barnhill

Use a caption to label the equations and a cross-reference to reference
them. Both Caption and Cross-reference are found in the Captions group on
the References tab in Word 2007. Captions use SEQ fields that may or may not
update automatically (SEQ fields don't ordinarily, but captions may have
some extra Word magic); REF fields don't update automatically. Both are
updated at print time, when you switch to Print Preview, or when you Ctrl+A,
F9 to update fields.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org
 
P

Peter Jamieson

To get the numbering format you need /and/ the cross-referencing
capability, I believe you will need to
a. follow Suzanne's suggestion re. caption creation.
b. replace the standard { SEQ } field by something that will return
the correct sequence format (A,..,Z,AA,..,AZ, etc.

When you reference an "Equation" for example, Word relies on the fact
that you have used a SEQ sequence name "Equation", e.g.

{ SEQ Equation }

Unfortunately I don't believe any of the standard numbering formats you
can apply will do what you need. However, if you use the following
nested SEQ fields I think you will be OK for a 1- or 2-letter sequence.
I use the letter "i" to keep the field code as short as possible, so you
will either need to create a Caption label called "i", or modify the "i"
in these fields to be the caption label you want to use:

At the beginning of your document, you will need the following field:

{ SET f "ALPHABETIC" }

and optionally

{ SEQ i \r0 }

Then within each caption you will need

{ SEQ i \#"'{ =25-{ SEQ i c } \#"'';'{ =int({ SEQ i \c }/26) \*{ f } }'"
}{ =mod({ SEQ i \c },26)+1 \*{ f } }'" }


(You can get rid of most of the spaces in there if you prefer). There
may be a simpler formulation - I haven't tried to pare it down any further.

Each of the {} has to be the special "field brace pairs" that you can
insert using ctrl-F9.

Because that's quite a lot to insert, you're probably going to be better
off creating your entire caption text, including the nested fields, and
making an autotext/quick part out of it. I believe the resulting
captions can be referenced in the usual way, and that the
numbering/renumbering behaves properly when you insert/delete captions,
but you should check for yourself.

An option that requires a bit more preparation but has a simpler set of
field codes and is more easily extended to 3 or more letters is to
predefine a large number of Word Document Variables, which you can then
insert using DOCVARIABLE fields., e.g.

Use the following VBA to set up Document variables called x1, x2, x3,...

Sub CreateListNumbers()
Const s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim c As String
Dim i As Integer
Dim k As Integer
k = 0
For i = 0 To 26
If i = 0 Then
c = ""
Else
c = Mid(s, i, 1)
End If
For j = 1 To 26
k = k + 1
ActiveDocument.Variables.Add Name:="x" + Trim(Str(k)), Value:=c &
Mid(s, j, 1)
Next j
Next i
End Sub

Then in your captions, use the following nested { SEQ } field:

{ SEQ i \#"'{ DOCVARIABLE "x{ SEQ i \c }' }'" }

In this case, it's a bit easier to use an existing Caption label, e.g.

{ SEQ Figure \#"'{ DOCVARIABLE "x{ SEQ Figure \c }' }'" }

If you use the VBA to generate the necessary Document Variables in a
Word template, each document based on the template will contain the
variables. So you don't need to run the VBA again, and you dont' need to
distribute it or ask anyone else to run it.

Peter Jamieson

http://tips.pjmsn.me.uk
 
P

Peter Jamieson

Apologies if this turns up several times...

To get the numbering format you need /and/ the cross-referencing capability,
I believe you will need to
a. follow Suzanne's suggestion re. caption creation.
b. replace the standard { SEQ } field by something that will return the
correct sequence format (A,..,Z,AA,..,AZ, etc.

When you reference an "Equation" for example, Word relies on the fact that
you have used a SEQ sequence name "Equation", e.g.

{ SEQ Equation }

Unfortunately I don't believe any of the standard numbering formats you can
apply will do what you need. However, if you use the following nested SEQ
fields I think you will be OK for a 1- or 2-letter sequence. I use the
letter "i" to keep the field code as short as possible, so you will either
need to create a Caption label called "i", or modify the "i" in these fields
to be the caption label you want to use:

At the beginning of your document, you will need the following field:

{ SET f "ALPHABETIC" }

and optionally

{ SEQ i \r0 }

Then within each caption you will need

{ SEQ i \#"'{ =25-{ SEQ i c } \#"'';'{ =int({ SEQ i \c }/26) \*{
f } }'" }{ =mod({ SEQ i \c },26)+1 \*{ f } }'" }


(You can get rid of most of the spaces in there if you prefer). There may be
a simpler formulation - I haven't tried to pare it down any further.

Each of the {} has to be the special "field brace pairs" that you can insert
using ctrl-F9.

Because that's quite a lot to insert, you're probably going to be better off
creating your entire caption text, including the nested fields, and making
an autotext/quick part out of it. I believe the resulting captions can be
referenced in the usual way, and that the numbering/renumbering behaves
properly when you insert/delete captions, but you should check for yourself.

An option that requires a bit more preparation but has a simpler set of
field codes and is more easily extended to 3 or more letters is to predefine
a large number of Word Document Variables, which you can then insert using
DOCVARIABLE fields., e.g.

Use the following VBA to set up Document variables called x1, x2, x3,...

Sub CreateListNumbers()
Const s As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Dim c As String
Dim i As Integer
Dim k As Integer
k = 0
For i = 0 To 26
If i = 0 Then
c = ""
Else
c = Mid(s, i, 1)
End If
For j = 1 To 26
k = k + 1
ActiveDocument.Variables.Add Name:="x" + Trim(Str(k)), Value:=c & Mid(s,
j, 1)
Next j
Next i
End Sub

Then in your captions, use the following nested { SEQ } field:

{ SEQ i \#"'{ DOCVARIABLE "x{ SEQ i \c }' }'" }

In this case, it's a bit easier to use an existing Caption label, e.g.

{ SEQ Figure \#"'{ DOCVARIABLE "x{ SEQ Figure \c }' }'" }

If you use the VBA to generate the necessary Document Variables in a Word
template, each document based on the template will contain the variables. So
you don't need to run the VBA again, and you dont' need to distribute it or
ask anyone else to run it.


Peter Jamieson

http://tips.pjmsn.me.uk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top