It's easy to write TeX equations in Markdown documents and convert them to actual typeset equations using pandoc (version 1.18), either in a PDF document (through LaTeX) or an HTML document (through MathJax): surround math in $...$
for inline equations and $$...$$
for block equations.
However, there seems to be a discrepancy between MathJax and TeX syntax with special characters like %
. For instance, consider this sample document:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
$$\text{\% change} = \frac{x_2 - x_1}{x_1} \times 100$$
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Converting this to PDF via LaTeX using the command
pandoc test.md -o test.pdf
correctly produces an unescaped percent sign:
However, converting the same document to HTML with MathJax, using the command
pandoc test.md -s --mathjax -o test.html
incorrectly produces an escaped percent sign:
For now, I've been manually escaping/unescaping percent signs before converting my documents to PDF/HTML, which seems to defeat the purpose of having a master Markdown document that can convert to any format.
What is the correct way to handle escaped percent signs in both TeX and MathJax? Is there a setting in MathJax that allows special characters to be escaped? Do I need to tell LaTeX to accept unescaped percent signs in math mode?
\text{}
it's in... why not use\percent
instead? – mb21\text{}
(with the sole exception of$
to re-enter math mode), see the documentation. – Peter Krautzberger