LaTeX support in WIRIS plugins: Insights.
The WIRIS plugins integrates the WIRIS editor into the HTML editors. From release 3.0, it is possible to write LaTeX inside the HTML editor using the $$ notation. In any case, formulas will be converted and stored as MathML.
LaTeX is disabled in the WIRIS plugin for Moodle if the filter of TeX is enabled in order to avoid conflicts.
How to edit using LaTeX
For example, if you type $$\frac12$$ in your HTML editor and you save the page, you will get a page with the fraction is never clicked for this purpose but means that the WIRIS plugin is installed and works behind the scenes to cope with LaTeX.
Editing LaTeX in an HTML editor
The browser displays the formula
When you reedit the page, you will see again . Thus, during edition you get the LaTeX and you see the image of the formula in display time.
A nice feature provided by the WIRIS plugin is that you can still use the WIRIS editor with LaTeX formulas. If the caret is inside a formula, you can click the WIRIS editor icon to edit it. After submitting the WIRIS editor form, the old LaTeX is replaced by the new LaTeX formula.
Using the WIRIS editor to modify a LaTeX formula
LaTeX is manipulated as MathML
Above is described the user experience, but what is important to note is that formulas are actually stored and displayed using MathML.
Upon submit the HTML editor, the WIRIS plugins searches all $$ and converts the LaTeX into MathML. During this process, the plugin stores the MathML and the original LaTeX text written by the author. Thus, when displaying formulas, the MathML mechanism takes place.
MathML is used internally whatever you do with LaTeX
LaTeX is stored inside a MathML using a standard tag called <semantics>. Following the previous example:
<math xmlns="http://www.w3.org/1998/Math/MathML"> <semantics> <mfrac><mn>1</mn><mn>2</mn></mfrac> <annotation encoding="LaTeX">\frac12</annotation> </semantics> </math>
When the HTML editor is opened again, the stored LaTeX is recovered from the <semantics> tag and is displayed in the HTML editor area for further edition. What it is important to note is that it works even when the LaTeX cannot be converted into MathML while it is possible still to edit the erroneous LaTeX to fix any possible error.
Which LaTeX is supported?
The supported LaTeX depends on the effectiveness when translating from/to MathML. The limits are due to the following facts:
- Some formulas have no equivalence with MathML.
- LaTeX is an extensible language with a lot of non-official packages. To do things worse, LaTeX has its own programming language.
Some examples about the current LaTeX supported can be found here.
var _wrs_conf_parseModes = ['latex'];
var _wrs_conf_parseModes = ;