Monday, September 29, 2014

MS Word Series: Texsword

In the previous article, I have introduced an add in called texsword. Besides using latex style to generate equation, you can also use its functionality to number your typed equation using MS Word.

The [square root button] in the texsword [add-ins] tab will produce a three columns table. The first column is for the equation, the second column is for the bookmark name and the third column for equation number.

Reset Equation Numbering


1) Press [Shift+F9] to show the field
2) Add [\r 1] in the field to reset the number to 1 or any intended number. For example {SEQ Eq \r 1} where SEQ is for sequence number and Eq is a variable used by texsword to name the equation.
3) Press [F9] to update

Add Heading To The Equation Number


1) Open texsword via open command in MS Word.
2) Press [Alt+F11] to bring up the VB Editor.
3) On the left side, double click on [Module -> texsword_equation] to bring up the codes.
4) Go to TeXsword_bookmark() subroutine and you will see codes

' Draw ()
    Selection.TypeText Text:="("
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
        "SEQ Eq", PreserveFormatting:=True
    Selection.TypeText Text:=")"
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend

5) Change the codes as follows

' Draw ()
    Selection.TypeText Text:="("
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
        "STYLEREF \s ""Heading 1""", PreserveFormatting:=False
    Selection.TypeText Text:="."
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
        "SEQ Eq", PreserveFormatting:=True
    Selection.TypeText Text:=")"
    Selection.MoveLeft Unit:=wdCharacter, Count:=1
    Selection.MoveLeft Unit:=wdCharacter, Count:=3, Extend:=wdExtend

The "Heading 1" can be changed to other headings when necessary.




No comments: