Math block $$…$$

Math blocks encode mathematical formulas to be displayed separately from text on the webpage like this:


The related math string markup can be used to write formulas compactly within lines of text.

How to

Choose and add a math module to your Aneamal installation, if you haven’t already. You can find free modules in the math modules inventory. Adding one to Aneamal is as easy as pie.

Then mark both the start and the end of a mathematical formula with double dollar signs like in the examples below.

You have the option to add a label at the end, separated by white space from the double dollar signs. If you mark the label as a target like in the third example, you can use it to link to the math block.

Due to being block markup, a math block usually needs to be preceded and followed by a blank line except when it is at the start or end of a file respectively. Unusually, a math block can also be used as list item. It is not accompanied by blank lines then.

Because the content of a math block is processed by a math module, its internal syntax is beyond the scope of Aneamal. Math modules should support the syntax of AMS-LaTeX. They usually omit some rarely used functions and add others. Consult their respective documentation, for example the supported functions in KaTeX.


 &=13\times\underbrace{4\times 7}_{28}+1
\begin{aligned} 365&=31+28+31+30+31+30+31+31+30+31+30+31\\ &=13\times\underbrace{4\times 7}_{28}+1 \end{aligned}

The next example uses a math label to identify an equation. Equation (2) is a formula to calculate the area A of a rectangle when its aspect ratio r and the length of its diagonal d are known.

$$A=\frac{d^2}{r+r^{-1}}$$ (2)

The following example turns the math label into a target. It can be used to link to equation (3), which shows a relationship between powers of the golden ratio \phi and Fibonacci numbers F_x.

$$\phi^n=F_n\phi+F_{n-1}$$ #(3)

For developers

When Aneamal is translated to HTML, a processed math block is enclosed in an HTML div element with a math role. The optional math label is included at the end as a span element with the class _label. The above examples become:

<div role='math'>
<div role='math'>
<span class='_label'>(2)</span>
<div id='3' role='math'>
<span class='_label'>(3)</span>

Note how in the last example the id attribute, which is derived from the target at the start of the math label, is added to the div element instead of to the span element.

Different math modules translate the same mathematical formulas differently to HTML, so the content of the div element will vary from module to module.