Here is an example, latexmath:[e^{i \pi} + 1 = 0].
It is easy to have LaTeX math formulas inside AsciiDoc documents and Yawg supports it out of the box. In this section we describe how to include math formulas in AsciiDoc content to be baked by Yawg.
Internally, Yawg uses Asciidoctor for processing AsciiDoc files. Yawg makes use of the Asciidoctor facilities for supporting equations and formulas. The actual rendering of the equations in the final HTML page is done by the wonderful MathJax Javascript display engine.
As usual in LaTex we have two ways to include math formulas in the text:
Inline math mode — The formula is shown inline with the text. Like when you want to say that \(\sin^2 x + \cos^2 x = 1\) is as obvious as \(\pi\).
Display math mode — The formula is shown in a dedicated paragraph. This is tipically used for larger formulas or equations.
In the following sections we describe how to include these two types of math formulas in AsciiDoc content.
We can have the equivalent of LaTeX inline math in our AsciiDoc documents. Here is an example, \(e^{i \pi} + 1 = 0\).
A math formula in inline math mode is created using the latexmath
macro. The last statement of the previous paragraph is obtained with
the content shown below.
Here is an example, latexmath:[e^{i \pi} + 1 = 0].
In display math mode a formula is shown in its own paragraph. A math
formula in display math mode is created using an AsciiDoc passthrough
block with the latexmath
style. You can see an example equation
below.
The pretty equation above is obtained with the piece of AsciiDoc markup shown below.
[latexmath]
++++
\frac{\partial V}{\partial t}
+ \frac{1}{2} \sigma^2 S^2 \frac{\partial^2 V}{\partial S^2}
+ r S \frac{\partial V}{\partial S}
- r V = 0
++++
In order for the equations to be appropriately displayed you need to
include the MathJax Javascript libraries in your HTML document
template. It is enough to add the following snippet to the <head>
section of your template:
<script
type="text/javascript"
async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
The above snippet will download the MathJax Javascript files from the MathJax content delivery network. If you are a MathJax expert you can of course tweak the above snippet to your heart’s content. MathJax provides very detailed documentation.