Automatically numbering equations with "3a" and "3b" and reference  
Author Message
superjas





PostPosted: Fri Sep 15 09:14:48 CDT 2006 Top

MS Word VBA >> Automatically numbering equations with "3a" and "3b" and reference

I have tried making {SEQ} fields various ways with unsatisfactory results.

What I would like is to create a sequence of equation numbers with bookmarks
to each equation so that I can reference them in the text and automatically
update them, even if I add or delete eqations, or want to number a pair of
eqations "3a" and "3b". The listnum commands all put something after the
number (a parenthesis or period) so I can't add an "a" or "b". The caption
command inserts bold, 10 pt formatting, which I don't want. Here is what
I've tried with the {SEQ} field:

When I Insert > Reference > Caption, my numbers are inserted with bold, 10
pt formatting, not the formatting of my text.

When I Insert > Field > SEQ, I get various errors:
"bookmark not defined", etc.

When I do CTRL+F9, and type inside { SEQ } followed by stuff, no number
appears when I toggle the field to show results.

I have tried the following manually entered field codes with no results
showing at the end:

{ SEQ Eqn }
{ SEQ Eqn Eqn1}
{ SEQ Eqn Eqn1 \* ARABIC }
{ SEQ Eqn Eqn1 \* ARABIC \n }
{ SEQ Eqn Eqn1 \* ARABIC \r 1}
{ SEQ Eqn \* ARABIC Eqn1}
{ SEQ Eqn [Eqn1] \* ARABIC }
{ SEQ Eqn "Eqn1" \* ARABIC }

and possibly other variations with or without bookmark names or \* MERGEFORMAT

I have also tried these variations using the Insert > Field codes dialogue,
and with the sequence name "test" instead of "Eqn".

Word30  
 
 
Shauna





PostPosted: Fri Sep 15 09:14:48 CDT 2006 Top

MS Word VBA >> Automatically numbering equations with "3a" and "3b" and reference Hi

About 90% of what you need is built-in to Word. There are several good
reasons to use the existing functionality rather than trying to re-invent
too many wheels.


> When I Insert > Reference > Caption, my numbers are inserted with bold, 10
> pt formatting, not the formatting of my text.
That's because Word puts all captions into the Caption style. If you don't
like the way the Caption style is formatted (eg you prefer a different font
or size), modify the Caption style. More info here:
How to modify styles in Microsoft Word
http://www.ShaunaKelly.com/word/styles/ModifyAStyle.html

> When I do CTRL+F9, and type inside { SEQ } followed by stuff, no number
> appears when I toggle the field to show results.
That's because you must update the field (with F9) to get it to show the
field results.

I suggest you proceed like this.

1. Whatever it is that determines the 3 in your "3a" and "3b" sequence needs
to be formatted using one of Word's built in heading styles. For info on
numbering your headings, see
How to create numbered headings or outline numbering in your Microsoft Word
document
http://www.ShaunaKelly.com/word/numbering/OutlineNumbering.html


2. Insert > Reference > Caption. In the Label box, choose Equation. Click
Numbering. Under Format, choose "a, b, c". Tick the "include chapter number"
box. Identify the heading level that contains the numbered heading that's
going to generate the "3". You don't want a Separator, so it doesn't matter
what's chosen in that list. Click OK.

You now have a caption that says something like "Equation 1-a". We have to
remove the "-", but it's hard to do with it surrounded by fields. So, Tools
> Options > View. In the Field Shading box, choose "Always". That will
display all fields shaded in grey. The shading does not print. You can turn
this off again later if you choose.

Now, carefully, remove the "-". So it says "Equation 1a".


3. It's typical to centre equations, and put the number against the right
margin. To do that, put your equation in a 1-row, 2 column borderless table.
So create such a table. Make the left cell quite large. It's for the
equation, but leave it blank for the moment. The number goes in the
right-hand cell. So copy the caption you created that says "Equation 1a" and
paste it into the right cell of your table.

You're now ready to put your equation in the left hand cell of the table.
But don't do that just yet.


4. Whenever you want to create an equation, you'll have to create a table
and put the number in the right-hand cell. To save all that effort, you can
create an AutoText to make it easy to create a new equation. So, click
somewhere in the table. Do Table > Select > Table. Now, do Alt-F3. Give your
AutoText a name. You can now use Tools > Customize to create a toolbar
button for your AutoText, or create a keyboard shortcut. More about
Autotexts at:
Using AutoText
http://www.word.mvps.org/FAQs/Customization/AutoText.htm


5. Whenever you want an equation, invoke your AutoText, and insert the
equation into the left-hand cell.


6. Note that caption numbers do not update automatically. To update one
caption number, click within it and do F9. Or, to update them all, do ctrl-a
to select all the text, then do F9.


7. To create a cross-reference to an equation, do Insert > Reference > Cross
Reference. In the Reference Type list, choose Equation. Make other choices
according to what you need.


8. To create a list of equations, do Insert > Reference > Index and Tables.
On the "Table of Figures" tab, in the Caption Label box, choose Equation.
Select other settings according to what you need and click OK.


Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word




>I have tried making {SEQ} fields various ways with unsatisfactory results.
>
> What I would like is to create a sequence of equation numbers with
> bookmarks
> to each equation so that I can reference them in the text and
> automatically
> update them, even if I add or delete eqations, or want to number a pair of
> eqations "3a" and "3b". The listnum commands all put something after the
> number (a parenthesis or period) so I can't add an "a" or "b". The
> caption
> command inserts bold, 10 pt formatting, which I don't want. Here is what
> I've tried with the {SEQ} field:
>
> When I Insert > Reference > Caption, my numbers are inserted with bold, 10
> pt formatting, not the formatting of my text.
>
> When I Insert > Field > SEQ, I get various errors:
> "bookmark not defined", etc.
>
> When I do CTRL+F9, and type inside { SEQ } followed by stuff, no number
> appears when I toggle the field to show results.
>
> I have tried the following manually entered field codes with no results
> showing at the end:
>
> { SEQ Eqn }
> { SEQ Eqn Eqn1}
> { SEQ Eqn Eqn1 \* ARABIC }
> { SEQ Eqn Eqn1 \* ARABIC \n }
> { SEQ Eqn Eqn1 \* ARABIC \r 1}
> { SEQ Eqn \* ARABIC Eqn1}
> { SEQ Eqn [Eqn1] \* ARABIC }
> { SEQ Eqn "Eqn1" \* ARABIC }
>
> and possibly other variations with or without bookmark names or \*
> MERGEFORMAT
>
> I have also tried these variations using the Insert > Field codes
> dialogue,
> and with the sequence name "test" instead of "Eqn".