Does mathjax-latex work? Not entirely if Markdown is enabled.

I have updated to PhP 7.2 FastCGI and WordPress 5.2. I want to use WordPress to display markdown documents that have some latex, so I've installed a plugin for markdown which seems to work. However, I'm getting mixed results with "mathjax-latex". Perhaps markdown and mathjax-latex were not meant to cooperate, I will need to do more testing.

The main issue is that the LaTeX markup that does work in a markdown document that we export to HTML with, say pandoc, does not work "as is" with mathjax-latex. In particular, to get in-line math, special markup seems required.

I can easily show the result of failed efforts, but have difficulty showing the markup. The ordinary markdown code tricks, like indenting four spaces or enclosing in ```, seem not to protect code from latex interpretation.

For inline math, the single dollar sign does not work. Observe, you see dollars $x_i$. However, writing the words "latex" within hard brackets "[" does work, along with "["/latex"]". The symbol "["latex"]" is converted to slash-paren, "\ (". Also I can explicitly type a double escaped "\\ (". Here is a gamma inserted inline with the first method: \(\gamma\), and using the second method \(\gamma\). Here is another Einstein favorite with the double-backslashed parenthesis: \(E=mc^2\), but the single dollar sign is a dud $E=mc^2$. However, if I literally write '$latex' at the beginning, it works: \(E=mc^2\).

Here is an example where the dollar sign notation does not work: This x sub i is at the end of a line: $x_i$. That is a big disappointment because all of my example documents use that notation. Just now I wonder about using escapes, '\$x_i\$'. Fail!

But if I put double dollar sign xsub i on line by itself, we get a displayed equation,


Double dollar signs work to get a display equation works OK if the dollar signs are on lines by themselves, which is happy news.


Bad news: the preferred LaTeX markup "\[" does not work to give an inline equation:

E = mc^2

To make that work, apparently I need a double back slash. That's unfortunate.

Here is a double back slash hard bracket, to show it can work:


I use double backslashed "\begin{equation}" to try for a labeled/numbered display:


No number, and label doesn't work, trying to cross-reference, equation(\ref{eq:gam}) fails.

So, LaTeX that begins with a backslash apparently needs a double backslash, but that does not work for all \LaTeX, as you see from the fact that LaTeX is not displayed with any special markup.

About pauljohn

Paul E. Johnson is a Professor of Political Science at the University of Kansas. He is an avid Linux User, an adequate system administrator and C programmer, and humility is one of his greatest strengths.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply