Basics of MathML
In the last couple of years, we’ve discovered different ways of creating MML which can widely change the appearance of an equation in an ePub. This document will share the most recent and efficient ways for creating MML in a word document which can be useful for tech writers and DTP.
Microsoft Office Pre-settings:
It is important to remember that quotations in MML need to be straight because we are showing measurements in feet and inches. Microsoft will autoformat quotations to be slanted unless you change this as a pre-setting. Do this by following the path:
Word > Preferences > AutoCorrect > AutoFormat As You Type Uncheck the box that says, "Straight quotes" with "Smart quotes".
Another important pre-setting is to choose how Microsoft Office copies and pastes the math equations. We need the equations to paste as MML text. To make sure this setting is activated, go to:
Format > Equation Options
Go to the section that says "When copying an equation," and select "Copy MathML to the clipboard as plain text."
For Tech Writers and Editors:
How to Style MML and other Equations:
The first basic step is to use the correct style in a TG manuscript. Some equations are very simple and can be typed in the manuscript without the need for the MML equation
builder. For example, an equation such as "y = mx + b" can simply be styled as Section.Equation.
If the equation is complex and needs to be created by using the equation editor in Word, this will have to be styled as Section.Para. So in other words, it needs to be Section.Para for the MML to import correctly into the NCS.
For Tech Writers and DTPs:
How to Insert an Equation in Microsoft Word:
MML is created in a word document by inserting an equation. In the ribbon above, you can find this by following the path:
Insert > Symbols > Equation Or at the very top of the window:
Insert > Equation
The quickest way however, is to use the keyboard shortcut. On a Mac, it is "control" +
"=". On a PC, it is "alt" + "=". From there, you type the equation into the equation builder box.
Tips on Typing Equations:
Most mathematical symbols can be made with keyboard shortcuts so the actual time it takes to make an equation is mere seconds. Spaces are not necessary unless to separate words.
Here's an example:
𝑇𝑜𝑡𝑎𝑙 𝑎𝑟𝑒𝑎 = 40 × 20 × 1 2⁄ You can find a list of keyboard shortcuts by going to:
Word > Preferences > AutoCorrect > Math AutoCorrect
For instance, if you want a multiplication symbol, simply type "\times" and it will automatically become a multiplication symbol. Common commands are:
π is "option" + "p"
÷ is "option" + "/"
Ω is "option" + "z"
Division signs still need to be created from the Equation ribbon however if there is a need to type it out in a regular paragraph, you can superscript and subscript the numerals.
Make sure to use the correct division symbol. Type "option" + "shift" + "1" and it will look like this: "⁄".
Notice the difference: 2⁄4 vs 2/4
For DTPs:
Manually Inserting an equation from the equation builder into Oxygen:
Create these tags before inserting the equation:
<section>
<equation-block>
<mathml>
INSERT EQUATION HERE </mathml>
</equation-block>
</section>
Delete the <math></math> tags.
Copy and paste the equation into the <mathml> tags and you will get this MML:
<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML"
xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<mml:mi>T</mml:mi>
<mml:mi>o</mml:mi>
<mml:mi>t</mml:mi>
<mml:mi>a</mml:mi>
<mml:mi>l</mml:mi>
<mml:mi> </mml:mi>
<mml:mi>a</mml:mi>
<mml:mi>r</mml:mi>
<mml:mi>e</mml:mi>
<mml:mi>a</mml:mi>
<mml:mo>=</mml:mo>
<mml:mn>40</mml:mn>
<mml:mo>×</mml:mo>
<mml:mn>20</mml:mn>
<mml:mo>×</mml:mo>
<mml:mfrac bevelled="true">
<mml:mrow>
<mml:mn>1</mml:mn>
</mml:mrow>
<mml:mrow>
<mml:mn>2</mml:mn>
</mml:mrow>
</mml:mfrac>
</mml:math>
To make it compatible, find/replace "mml" with just "m." Delete the second xmlns http line.
Once it is compatible and in the right tags, your equation will look like this:
<section>
<equation-block>
<mathml>
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:mi>T</m:mi>
<m:mi>o</m:mi>
<m:mi>t</m:mi>
<m:mi>a</m:mi>
<m:mi>l</m:mi>
<m:mi> </m:mi>
<m:mi>a</m:mi>
<m:mi>r</m:mi>
<m:mi>e</m:mi>
<m:mi>a</m:mi>
<m:mo>=</m:mo>
<m:mn>40</m:mn>
<m:mo>×</m:mo>
<m:mn>20</m:mn>
<m:mo>×</m:mo>
<m:mfrac bevelled="true">
<m:mrow>
<m:mn>1</m:mn>
</m:mrow>
<m:mrow>
<m:mn>2</m:mn>
</m:mrow>
</m:mfrac>
</m:math>
</mathml>
</equation-block>
</section>
Special Coding to use in Oxygen:
Sometimes you will need to work with the MML coding in Oxygen to achieve certain attributes such as underlining a portion of the equation or using colors and font styles.
If you want to underline something within an equation, it would look like this:
<m:menclose notation="bottom">
<m:mfenced separators="|">
<m:mrow>
<m:mn>3</m:mn>
<m:mo>+</m:mo>
<m:mn>3</m:mn>
</m:mrow>
</m:mfenced>
</m:menclose>
Within the actual MML equation:
<section>
<equation-block>
<mathml>
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:menclose notation="bottom">
<m:mfenced separators="|">
<m:mrow>
<m:mn>3</m:mn>
<m:mo>+</m:mo>
<m:mn>3</m:mn>
</m:mrow>
</m:mfenced>
</m:menclose>
<m:mi mathvariant="normal"> </m:mi>
<m:mo>×</m:mo>
<m:mi mathvariant="normal"> </m:mi>
<m:mn>2</m:mn>
<m:mo>-</m:mo>
<m:mn>6</m:mn>
<m:mo>÷</m:mo>
<m:mn>3</m:mn>
<m:mo>+</m:mo>
<m:mn>1</m:mn>
<m:mo>=</m:mo>
<m:mi mathvariant="normal"> </m:mi>
<m:mo>?</m:mo>
</m:math>
</mathml>
</equation-block>
</section>
Using colors in MML
If you have a NEC reference within an equation, it needs to have the correct color. We use the style PHPhrase which has a shade of green labelled as #4d823b; and is italic. This information can be found in the TG.css.
Here you can see how to make the text both green and italic:
<m:mstyle displaystyle="true" mathcolor="#4d823b">
<m:mrow>
<m:mi fontstyle="italic">NEC 143.60(A)</m:mi>
</m:mrow>
</m:mstyle>
Here is the entire equation:
<section>
<equation-block>
<mathml>
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:mfrac>
<m:mrow>
<m:mn>24</m:mn>
<m:mn>π</m:mn>
<m:mo>×</m:mo>
<m:mstyle displaystyle="true" mathcolor="#4d823b">
<m:mrow>
<m:mi fontstyle="italic">NEC 143.60(A)</m:mi>
</m:mrow>
</m:mstyle>
</m:mrow>
<m:mrow>
<m:mn>10</m:mn>
</m:mrow>
</m:mfrac>
</m:math>
</mathml>
</equation-block>
</section>
MML Strikethrough:
There are two methods for creating a strikethrough line in MML characters:
1. In Oxygen, go to Edit, Insert from Character Map, and type U+0338 in the search box.
Make sure to have "hexadecimal" checked. Insert the Unicode after the character you want to have affected.
2. When creating MML, you can use <m:menclose notation="updiagonalstrike" to put a strike through anything within these brackets. Here's the equation:
<section>
<equation-block>
<mathml>
<m:math xmlns:m="http://www.w3.org/1998/Math/MathML">
<m:mfrac>
<m:mrow>
<m:menclose notation="updiagonalstrike">
<m:mn>24</m:mn>
</m:menclose>
<m:mn>+
</m:mn>
<m:mrow>
<m:mi>15A̸</m:mi>
</m:mrow>
</m:mrow>
<m:mrow>
<m:menclose notation="updiagonalstrike">
<m:mn>10</m:mn>
</m:menclose>
</m:mrow>
</m:mfrac>
</m:math>
</mathml>
</equation-block>
</section>