This works really well so far:
- Click on the equation number to select it, then click Insert, Bookmark.
- Assign a meaningful name to the Bookmark (bookmark names should start with a letter and should not include any spaces), and click Add. Repeat this process for any equation that you wish to reference.
- To create a cross reference to the equation somewhere in your text, click Insert, Cross Reference.
- Under Reference Type select Bookmark, and from the presented list of bookmarks, choose the appropriate one. Under Insert reference to select Paragraph number (full context) and click Insert.
The full article is available here
I name my bookmarks staring with "eq_", e.g. "eq_area_of_circle".
I can then reference "eq_area_of_circle" as:
A = pi * r^2 (4)
The area of the circle mentioned can be calculated using (4).
I saw your question on Stack Overflow, where it was really "too broad" as formulated, but it intrigued me.
It can be done, although not completely automatically, manually and/or with VBA.
- Select any (an empty) paragraph and apply a
Frame
to it. You can find the Insert Frame
command in the Developer
tab of the ribbon, Controls group, Legacy controls. It's the fourth control from the left
- Size the frame, apply the font size you want for the numbers, etc.
- Right-click the frame to get to the Format Frame dialog box. For the horizontal position select
Outside
relative to the Page and fine-tune the distance from the text if necessary. Vertical position should be 0 relative to the paragraph. Make sure "Move with text" and "Lock anchor" are activated. When the dialog box is confirmed the framed paragraph should move to the outside margin of the immediately following paragraph.
- Create a new style from this paragraph - it will include the Frame definition.
- Test the style by typing in or selecting another empty paragraph and applying the style to it.
The numbering can be generated by placing an SEQ field in each frame, then updating the fields in the document.
At this point, manually, it would be possible to generate the numbering. A long task, of course, for a large document. The following code will cycle all paragraphs in a document, inserting an empty paragraph, an SEQ field and formatting it with the style. At the end, all the fields are updated.
This will, almost certainly (based on the screen shots you show) insert more numbers than you want. You can either go through and delete them manually or alter the code to ignore paragraphs that meet the particular criteria that should not be numbered, or alter the code to skip those paragraphs when generating the frames.
In this code, the style for the frames is named NrPara
; if you use a different name you need to change this.
Sub NumberParas()
Dim doc as Word.Document
Dim Para As Word.Paragraph
Dim rngPara As Word.Range, rngParas() As Word.Range
Dim numParas As Long, counterPara As Long
Dim numParaStyle As Word.style
Dim rngNumPara As Word.Range
Dim sSEQ As String
sSEQ = "SEQ ParaNum"
Set doc = ActiveDocument
numParas = doc.Paragraphs.Count
ReDim rngParas(numParas - 1)
'Get an array of the paragraph ranges
For counterPara = numParas To 1 Step -1
Set Para = doc.Paragraphs(counterPara)
Set rngPara = Para.Range
Set rngParas(counterPara - 1) = rngPara
Next
'Insert a paragraph above each existing one, format and insert SEQ field
For counterPara = LBound(rngParas) To UBound(rngParas)
Set rngPara = rngParas(counterPara)
With rngPara
.InsertBefore vbCr
.Collapse wdCollapseStart
.Fields.Add rngPara, wdFieldEmpty, sSEQ, False
rngPara.style = "NrPara"
End With
Next
doc.Fields.Update
End Sub
Best Answer
Creating the labels
It should look this way:
{ STYLEREF 1 \s }.{ SEQ eqn \* Arabic \s 1 \* MERGEFORMAT }
Click into each of the curly brackets once and type F9 each time. You get this:
You can do this as well by clicking via "Insert -> Text -> Quick Parts -> Field ...".
How does it work?
This page might help understanding how SEQ works: http://wordribbon.tips.net/T008180_Numbering_with_Sequence_Fields.html
Auto-Insert the label
This idea comes from here: https://cybertext.wordpress.com/2010/03/08/word-2007-setting-up-seq-fields-for-numbering-pt-1/
This can be combined with Calchas solution in How do you easily add equation numbers to Microsoft Word 2010 equations? . At least I do it.
Cross-Referencing
I do it with bookmarks: