Chapter 25. Mathematical Formulas

The asciimath and latexmath passthrough blocks along with the asciimath and latexmath passthrough macros provide a (backend dependent) mechanism for rendering mathematical formulas. You can use the following math markups:

25.1. LaTeX Math

LaTeX math can be included in documents that are processed by dblatex(1). Example inline formula:

latexmath:[$C = \alpha + \beta Y^{\gamma} + \epsilon$]

For more examples see the AsciiDoc website or the distributed doc/latexmath.txt file.

25.2. MathJax

MathJax allows LaTeX Math style formulas to be included in XHTML documents generated via the AsciiDoc xhtml11 and html5 backends. This route overcomes several restrictions of the MathML-based approaches, notably, restricted support of MathML by many mainstream browsers. To enable MathJax support you must define the mathjax attribute, for example using the -a mathjax command-line option. Equations are specified as explained above using the latexmath passthrough blocks. By default, rendering of equations with MathJax requires a working internet connection and will thus not work if you are offline (but it can be configured differently).

25.3. LaTeXMathML

LaTeXMathML allows LaTeX Math style formulas to be included in XHTML documents generated using the AsciiDoc xhtml11 and html5 backends. AsciiDoc uses the original LaTeXMathML by Douglas Woodall. LaTeXMathML is derived from ASCIIMath and is for users who are more familiar with or prefer using LaTeX math formulas (it recognizes a subset of LaTeX Math, the differences are documented on the LaTeXMathML web page). To enable LaTeXMathML support you must define the latexmath attribute, for example using the -a latexmath command-line option. Example inline formula:

latexmath:[$\sum_{n=1}^\infty \frac{1}{2^n}$]

For more examples see the AsciiDoc website or the distributed doc/latexmathml.txt file.

[Note]

The latexmath macro used to include LaTeX Math in DocBook outputs is not the same as the latexmath macro used to include LaTeX MathML in XHTML outputs. LaTeX Math applies to DocBook outputs that are processed by dblatex and is normally used to generate PDF files. LaTeXMathML is very much a subset of LaTeX Math and applies to XHTML documents. This remark does not apply to MathJax which does not use any of the latexmath macros (but only requires the latexmath passthrough blocks for identification of the equations).

25.4. ASCIIMath

ASCIIMath formulas can be included in XHTML documents generated using the xhtml11 and html5 backends. To enable ASCIIMath support you must define the asciimath attribute, for example using the -a asciimath command-line option. Example inline formula:

asciimath:[`x/x={(1,if x!=0),(text{undefined},if x=0):}`]

For more examples see the AsciiDoc website or the distributed doc/asciimath.txt file.

25.5. MathML

MathML is a low level XML markup for mathematics. AsciiDoc has no macros for MathML but users familiar with this markup could use passthrough macros and passthrough blocks to include MathML in output documents.