Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?

From
Thomas Schraitle <>
Date
2015-01-29T20:30:03+00:00
ID
5194814.txqsERuriD@erde
Thread
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
Hello Marco,

Am Donnerstag, 29. Januar 2015, 20:46:30 schrieb Marco Giebel:
> [...]
> My idea is to include some <latexmath> element in a document like
>
> <para>
> <latexmath>\sum_{n=1}^\infty \frac 1 n</latexmath> is divergent.
> </para>

There is no <latexmath> element in DocBook. However, you can have the same 
functionality with equation (for block formulas) or inlineequation (inside a 
paragraph). For example, an inline equation of Einsteins famous formula could 
look like:

 <inlineequation>
   <mathphrase role="latex">E = mc^2</mathphrase>
 </inlineequation>

 
> This element should be translated to MathML during processing - either as a
> preprocessing step or using xslt commands if possible.
> 
> Can this be done? Or do I have to parse my documents, find all <latexmath>
> elements, process their contents with LatexML and write the MathML output
> back into the document?

Sure. In theorey, it needs a three step process: extract all LaTeX formulas, 
convert it to MathML (or maybe graphics?), and reinsert it -- or include a 
reference.

How many formulas do you have? Do they change frequently? Well, maybe you 
don't need such a sophisticated convertion. Perhaps you could reference your 
MathML formulas with xi:include and do the convertion outside your workflow.

Get some ideas by reading Bob's chapter about Math in DocBook at 
http://www.sagehill.net/docbookxsl/Math.html

Hope this helps. :)

-- 
Gruß/Regards
  Thomas Schraitle