WordPress.com supports the use of standard LaTeX in posts and comments, which is displayed using embedded PNG images with the LaTeX source code appearing in the alt text. So, including inline maths in your comments is easy! All you have to do is to surround your $\LaTeX$ code by the tags $latex …$. For example, typing

 $latex \int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt\pi$

gives $\int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt\pi$. Note that the initial space after the opening $latex is necessary. If this is omitted then the code will not be processed as LaTeX and will just appear as typed. There are some problems that can occur, but are easily avoided. As WordPress.com has some support for html in comments, any < or > signs could be misinterpreted as html tags, messing up the comment. This is avoided by either ensuring that spaces are left around these symbols or by using &lt; and &gt; in place of < and > respectively. Also, you can have newlines in your LaTeX code, which is treated as whitespace as with regular LaTeX. However, do not put a newline directly after the opening$latex, as this prevents the LaTeX code from being processed. Any LaTeX containing errors is displayed as $\badlatex$.

Unfortunately, WordPress.com does not support previewing or editing comments. So, if you want to test your LaTeX code before posting as a comment, feel free to first post it as a comment here. Also, I will correct any incorrectly entered LaTeX in comments as I come across them. Happy commenting!

The displaymath environment

In standard LaTeX it is possible to use the displaymath environment, which causes the formula to appear centered on its own line, with whitespace above and below, and with slightly different formatting making use of the additional space. WordPress.com does not directly support displaymath but, fortunately, it is possible to emulate it with inline LaTeX. This requires doing two things. First, use the html p (paragraph) tag to insert whitespace above and below the expression with the align attribute set to “center”. Then, the expression can be made to appear with the correct displaymath formatting by starting it with the \displaystyle LaTeX keyword. For example, typing



$latex \displaystyle\int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt\pi$

gives

$\displaystyle\int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt\pi$

Typing this afresh every time you want to display a formula is likely to lead to mistakes, so you can simply copy the expression above directly from this page and paste it into your comment, replacing my LaTeX code with yours while retaining the \displaystyle command.

Multiline expressions and alignment

It is often desirable to break long formulas and expressions down into multiple lines. In standard LaTeX this can be done with the align environment, which uses \\ to end a line and aligns the expressions on the & character. However, the align environment is not supported in WordPress. Instead, the array environment can be used, as this works with standard LaTeX inside inline maths formulas. There are some things that should be done to get this to display properly though. To reduce the rather excessive amount of space that appears in place of the & alignment characters, the command \setlength\arraycolsep{2pt} should be used immediately before entering the array environment. Secondly, to make sure that enough space appears between lines, put \smallskip immediately before the \\ command for a newline. Also, to get correct displaymath formatting, the \displaystyle command should be reentered after every & alignment character and at the start of each line. You can copy and paste the following text into your comment, replacing [my-latex] with your LaTeX code.



$latex \setlength\arraycolsep{2pt}\begin{array}{rl} \displaystyle[my-latex]&\displaystyle[my-latex]\smallskip\\ \displaystyle[my-latex]&\displaystyle[my-latex] \end{array}$

For example, the following multiline expression

$\setlength\arraycolsep{2pt}\begin{array}{rl} \displaystyle\int_{-\infty}^\infty e^{-x^2}\,dx&\displaystyle=\sqrt\pi,\smallskip\\ \displaystyle\int_{-\infty}^\infty e^{-ax^2}\,dx&\displaystyle=\int_{-\infty}^\infty e^{-y^2}\frac{dy}{\sqrt a}\smallskip\\ &\displaystyle=\sqrt{\frac\pi a} \end{array}$

was produced by typing the following text.



$latex \setlength\arraycolsep{2pt}\begin{array}{rl} \displaystyle\int_{-\infty}^\infty e^{-x^2}\,dx&\displaystyle=\sqrt\pi,\smallskip\\ \displaystyle\int_{-\infty}^\infty e^{-ax^2}\,dx&\displaystyle=\int_{-\infty}^\infty e^{-y^2}\frac{dy}{\sqrt a}\smallskip\\ &\displaystyle=\sqrt{\frac\pi a} \end{array}$

Equation numbering

LaTeX documents support the use of equation numbering. This displays a right-aligned number inside parentheses after displayed equations, as follows.

 $\displaystyle\int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt\pi.$ (1)