# Converting Equations from MathType to Word 2007's Equation Format

MathType users may want to convert their equations to Word 2007's native equation format. This can be done by exporting the equations in MathML and then pasting them into Word 2007. There are some problems and useful tricks that Dadi Gudmundsson (www.sensoranalytics.com) describes as follows:

Migration Procedure

Reason for migration

After testing the equation capability in Word 2007 I was immediately sold. There are some things that need to be smoothed out, but the bottomline is that my overall productivity of documenting and maintaining mathematical content was greatly improved. See also my posting on:

1. Convert Mathtype to Mathml

I kept my Word 2003 installation to have easy access to the Mathtype capability I had installed there. Using the Convert equations selection in the Mathtype pull-down menu I converted all 700 equations to "Mathtype 2.0 (no namespace)".

The document went from 60 to about 800 pages (this is temporary).

2. Edit Mathml notation

Through trial and error I discovered that it is apparently necessary to edit some Mathml notation for the equation capability of Word 2007. So, using Word 2003 or 2007, the following Find and Replace operations were done:

a. Find "<" and replace with "<mml:" (this will affect any "<" marks in the text that are not inside equations. Easy to find later.

b. Find "<mml:/" and replace with "</mml:"

c. Find "<mml:math" and replace with "<mml:math xmlns:mml="https://www.w3.org/1998/Math/MathML "

d. Be careful to not allow Word to change the quotation marks in the above text to "smart quotes" (Smart quotes have a more professional look and also slant to the appropriate sides). The equation capability needs the quotation mark to be the standard plain quotation mark shown above. To stop Word 2007 from doing this go into the dialog for the "AutoCorrect" feature, and in the "AutoFormat As You Type" tab, uncheck the "Straight quotes with smart quotes" selection.

3. Macro for equation conversion

Open the document in Word 2007 and convert it to become a Word 2007 document (can't do the following in compatibility mode). Start recording a macro and do the following for the first equation:

a. Open the Find feature, turn on wildcard & ignore whitespace selections, enter "?mml:math*/mml:math?" into the Find field and push Find. The first block of Mathml code should now be highlighted.

b. Push Ctrl+X to cut the selected text.

c. Push Alt+= to insert an equation.

d. Select paste special and paste as unformatted text (in majority of cases the mathml code in question will now appear as a human readable equation).

Stop recording the macro, close the Find feature dialog.

4. Fix an error in the Macro recording

For some reason the macro capability in Word does not remember the "paste special" selection we made while recording the macro. This a known issue. To fix it see the following link:

https://www.latext.com/pm/comments/M1107_0_1_0_C/

5. Assign the macro to a button or keystroke combination.

See Word help on how to do this.

6. Use the button to convert equations.

I chose to convert one equation at a time to make sure everything came out as expected. Using the side-by-side view, I referred to an untouched version of the original document (opened in compatibility mode). So I sat there and repeatedly pushed my new macro button and majority of the time the Mathml code would be translated into equations. I could confirm with a quick glance in the side-by-side view that the translations were successful.

Comments:

a. Some accent marks came out a bit weird, but no reason to edit them per se.

c. Some accent marks were almost invisible although they had entry fields created for them in the Word 2007 equations. I would manually fix those. After some trial and error I became quite proficient in editing equations in Word 2007.

b. Out of the approx. 700 equations, 10 Mathml translations did not translate. I re-did those manually.

c. If an equation was originally in a bulleted list, the Mathml code would now be in a long bulleted list. I would select the whole block of Mathml code, make it un-bulleted, move the cursor in front of the Mathml code, and then push the macro button.

d. This proceduce caused paragraphs to be broken into parts when the original MathType equations were in-line (inside paragraphs of text). This required some deletion of whitespace to re-assemble the paragraphs.

e. This took about 2 hours, but my team is now able to be much more productive. Here I am also measuring the productivity impact on my business when errors are made in documentation of mathematical formulations. These will make it into software products and cause all kinds of issues, worries, and possibly financial harm. These are errors that are frequently made when people are editing cryptic Latex source code, or when using the MathType capability with Word. In the latter case it is most often due to the equations they are working with on the screen being rendered worse than the surrounding text and/or the user has to focus on entering equations very carefullly as not to trigger software issues that arise when 100s of equations are present.

I hope this helps other users who want to do the same migration. I did my best to check this for errors, and ask that those who spot errors or know of simpler methods please write about it.

Thanks

Dadi Gudmundsson