_ _ | |_ ___ __| |____ ___ _ _ | __/ _ \/ _` |_ / / _ \ | | | | || __/ (_| |/ / | __/ |_| | \__\___|\__,_/___(_)___|\__,_|
I've been experimenting some more with using the lagrida.com online LaTeX equation editor to convert LaTeX equations into MathML that can be copied and pasted into a Jotz CMS article. It works quite well, but by default does not provide a record of the LaTeX used to create the equation, which would be required for later editing. There is an option in the Lagrida equation editor to add an "annotation" to the generate MathML that contains the original LaTeX. At first, I thought this worked okay, but it caused a problem when downloading the markdown for use with e.g. pandoc.
So far, the best solutions I've come up with is to add a HTML comment containing the LaTeX equation just before the MathML equation in the Jotz CMS article. Copying and pasting this into Jotz CMS requires some additional work, but it produces a markdown file that can (with a little automated pre-processing) be processed in pandoc to produce a PDF or whatever. Basically, the HTML comment will by ignored in Jotz CMS, but the MathML will render as an equation. To use the same markdown with pandoc, use sed to pre-process the file, stripping out all
The following is the markdown example I've been experimenting with:
This is the first paragraph of text. In Jotz CMS,
the HTML comments (each one containing a LaTeX equation),
but the `<math>` elements render correctly.
<!-- $$
\Large{E = mc^2}
$$ -->
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mstyle displaystyle="true" scriptlevel="0">
<mrow data-mjx-texclass="ORD">
<mtable rowspacing=".5em" columnspacing="1em" displaystyle="true">
<mtr>
<mtd>
<mstyle mathsize="1.44em">
<mrow data-mjx-texclass="ORD">
<mi>E</mi>
<mo>=</mo>
<mi>m</mi>
<msup>
<mi>c</mi>
<mn>2</mn>
</msup>
</mrow>
</mstyle>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</math>
From my applied maths classes of old:
<!-- $$
\Large{s = ut + \frac{1}{2}at^2}
$$ -->
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mstyle displaystyle="true" scriptlevel="0">
<mrow data-mjx-texclass="ORD">
<mtable rowspacing=".5em" columnspacing="1em" displaystyle="true">
<mtr>
<mtd>
<mstyle mathsize="1.44em">
<mrow data-mjx-texclass="ORD">
<mi>s</mi>
<mo>=</mo>
<mi>u</mi>
<mi>t</mi>
<mo>+</mo>
<mfrac>
<mn>1</mn>
<mn>2</mn>
</mfrac>
<mi>a</mi>
<msup>
<mi>t</mi>
<mn>2</mn>
</msup>
</mrow>
</mstyle>
</mtd>
</mtr>
</mtable>
</mrow>
</mstyle>
</math>
This is the last paragraph of text.
To process the above markdown using pandoc, it should first be pre-processed using the following sed command:
sed -s '/<math/,/<\/math/d;s/<!--.*$$/$$/;s/$$.*-->/$$/' test.md > test_pandoc.md
Then, to convert to PDF using pandoc...
pandoc test_pandoc.md -o test.pdf
The file test_pandoc.md contains the following:
---
title: Formatting experiment
...
This is the first paragraph of text.
$$
\Large{E = mc^2}
$$
From my applied maths classes of old:
$$
\Large{s = ut + \frac{1}{2}at^2}
$$
This is the last paragraph of text.
This is a screenshot of test.pdf (note: the full page is not shown here, but the PDF is a normal A4 document).
