17

MathML can be created and edited directly in the IGP:Writer interface. Tthere are multiple options for various format generation to compensate for the limitations of various reading systems. Modified: 14 December 2013

*IGP:Writer* has specific Content Blocks for MathML to allow it to be imported, inserted, edited and managed as both HTML5 Inline and Block MathML.

This assists the long-term management of Scientific, Technical, Mathematics and Education content that depend on MathML.

MathML blocks can be inserted as MathML inline or MathML in blocks. For example the MathML block can be inserted inside an equation-rw block.

MathML blocks are independent and present primarily as a processing target for ID generation, classification, image generation, extraction and reuse.

The MathML Editor allows ASCIIMath and MathML to be directly keyed or pasted into the interface. LaTeX is being evaluated for the near future.

If you have your MathML XML ready before creating a MathML block it must be available from a text file encoded as UTF-8.

- Insert your cursor in an empty paragraph in the position you want to insert your MathML block equation.
- From the
**Content Block**accordion find the**G08 MathML**button option. - Double-click the
**01 MathML Block**button. A MathML editing dialogue will open. - You can create and insert MathML by the following methods:
- Key or paste you equation using ASCIIMath directly into the left panel. Then click the
**Convert**button to generate the MathML. Click the**Preview**button to view the equation. - Key or paste your MathML into the right panel. Then click the
**Preview**button to view the equation in the Preview panel. If this is large the panel will be scrollable. - If your pasted MathML is continuous text, and you need to edit it, click the
**Pretty Print**button. This will process the MathML into an editing friendly presentation.

- Key or paste you equation using ASCIIMath directly into the left panel. Then click the
- Click the
**Insert**button to put the MathML into the Writer document and close the dialogue. - When you save the Writer document the MathML will be instantly available in the Reader and Print views.

*IGP:Writer* is an HTML5 framework. You do not need to enter namespace declarations in your MathML. This will be inserted by Formats On Demand packaging as and when required by various formats.

- Position your cursor in a paragraph at the position you want to insert the MathML. You should place a space on either side of the cursor position.
- From the
**Content Blocks**accordion from the**Inline Options**click the**MathML**Inline option. - The MathML dialog will open. You can now paste or key your MathML into the editing dialog. Click the insert button.
- The MathML will be immediately inserted into the Writer document and instantly appear on the Writer page.
- When you save the Writer document the MathML will be instantly seen in the Reader and Print views.

If you have MathML in your manuscript this can be imported depending on how it was produced.

There are two main tools used to produce MathML in MS Word documents: MathType and MathMagic. Libre Office equations can also be imported.

- MathType has an optional DaisyMath plugin.
- To use this you must export your MS Word document as DaisyXML with the DaisyMath plugin active. The output is a DaisyXML file.
- From Import Manuscript, select the Custom XML Tab, and then from the dropdown Daisy XML.
- Upload your document.
- Assuming it has been tagged correctly the full document and MathML will be imported, converted to HTML5 and be instantly available for ongoing editing.

It is important that your MathML has the display property set correctly (IE. <math display="block"> or <math display="inline">.

If the imported MathML has no display property it will be treated as a block by default. This means any inline equations will appear in the wrong position and may have to be repositions and have the block-type changed. This can be done using the MathML Editor and manually inserting the display="inline property.

We do not currently have a process for importing MathML from a Wordprocessor file created with MathMagic.

If your manuscript has MathML created using the standard Libre Office equation editor they can be exported to XHTML and imported directly into Writer with the MathML included.

- To export a Libre Office manuscript containing MathML from the File menu, click Export.
- Select export option: XHTML1.1 + MathML2.0 (.xhtml) (*xhtml).
- Choose your save location and click Save.

- To import the document into Writer, from the Import Manuscript option select the Custom XML tab and then from the selector HTML.
- Select the XHTML document from its location.
- Click the
**Import**button. - Your file will now be imported and processed to IGP:FoundationXHTML with MathML block processing.

The Maths editor in Libre Office also does not have the option to set the MathML display property to inline or block. Therefore the importer is guessing on the correct display value based on parent elements. There is a possibility of errors depending on the complexity of your MathML layout.

Because the Libre Office generated MathML inserts blocks into a paragraph the processor interpretes a single MathML block in a <p> with no other blocks or styles as a block equation.

Many browsers and reading systems do not support MathML either at all or well. In these cases you may need to convert MathML to images for the final format.

The MathML to image processor available that will convert all MathML to SVG, PNG and JPG images at internet resolution, and PNG at print resolution.

When you select your format packaging options the image substitution model can be selected.

Because MathML documents can contain very large numbers of equations and it takes significant time to generate the images from the MathML this is a stand-alone interface and should be done once before format generation. The format packagers expect images to be available.

To generate MathML images from MathML.

- Click the Editing Tools button.
- Click the Document Processors button.
- Scroll to the bottom of the interface where you will find the processor option MathML Image Processing.
- Use the options to select your requirements. You can generate images for Online, Print, the whole document or just the Active Section.

You can control the size of the images generated by the image processor.

In the Print and Reader CSS F01 Galley the following processing instruction block is available.

The SVG is generated at the galley font-size applied in the document.

By default the print images are generated as PNGs with background transparency and 300dpi resolution. If you want to increase the size of the images change the default size to your target size.

/* DOCUMENT CALCULATION OF MathML starts */ #mathml-image-inline { font-size: 12pt; } #mathml-image-block { font-size: 12pt; } /* DOCUMENT CALCULATION OF MathML ends */

/* DOCUMENT CALCULATION OF MathML starts */ #mathml-image-inline { font-size: 1em; } #mathml-image-block { font-size: 1em; } /* DOCUMENT CALCULATION OF MathML ends */

There is some advantage creating MathML images that are 2X larger than the default font size so in reading systems where the user can enlarge the font the presentation quality is maintained. In this case change the 1em statements to 2em and the image generator will create the images accordingly.

If you have a book or document containing a lot of MathML you can use the Statistics Report to generate counts of inline and bock equations.

Statistics Reports can be generated from the Book Toolbar in the Management Interface (click the **Stats** option), or from the document toolbar in **IGP:Writer**.

The HTML5 specification has made MathML a first level element group without the requirement for namespaces. This is carried forward in *IGP:FoundationXHTML*.

The preferred method for inserting MathML into *IGP:FoundationXHTML* is as a simple element with no name-space declarations in a defined mathml-rw element.

<span class="mathml-rw" ><math display="inline"> .... </math></span>

<div class="mathml-rw" ><math display="block"> .... </math></div>

See the *IGP:FoundationXHTML* specification for more information on the purpose of these tagging patterns.

If delivery formats require namespaces (such as XHTML5 for ePub3) the Formats On Demand processor will insert the required statements to ensure the final package is valid for any specific format.

For more background information and tutorials on the MathML production issues see these links.