TeX & LaTeX Formulas in AsciiDoc
Especially in academia, adding formulas is crucial. While other markup languages like LaTeX are rather verbose, AsciiDoc combines simple markups without losing complexity.
Activating Formulas
Activate the :stem:
attribute in the document header and select asciimath or latexmath. The selection changes the syntax to display STEM formulas in the preview and export. We use MathJax to render formulas.
Basic Syntax
As always, the adoc Coach helps you to remember the syntax. Write Stem and the completion menu gives you the full syntax.
// In-line Syntax
stem:[a^2+b^2=c^2]
// Block Syntax
[stem]
++++
\frac ab + {\displaystyle \frac cd + \frac ef} + \frac gh
++++

Mix & Match AsciiMath & LaTeXMath
Instead of defining the STEM Syntax once for all formulas, you can also change it for individual lines or blocks. Instead of using stem
, write asciimath
or latexmath
.
[asciimath]
++++
sum_(i=1)^n i^3=((n(n+1))/2)^2
++++
[latexmath]
++++
\def\specialFrac#1#2{\frac{x + #1}{y + #2}}
\specialFrac{7}{z+3}
++++
