Question

This is very simple question but I unfortunately didn't get any clue to get rid from this error. I am writing a blog post about jquery ajax where I need to write a symbol $. I am using Mathjax for writing mathematical notation. As I write $ (for example $.getJSON), the Mathjax library decodes this as LaTeX commands. Anybody knows how to skip that $ character so that MathJax library behaves it as normal $?

Was it helpful?

Solution

By default, MathJax does not use the single dollar as a delimiter for in-line math (for exactly the reason you indicate), and so your configuration must be explicitly enabling it. See the text2jax dpcumentation for details of how this is done.

You have several options:

  1. Remove the configuration that turns on dollar signs for in-line math. (This won't be good if you have already used them for in-line math in other posts)

  2. Enable the processEscapes option so that you can use \$ to get a dollar without it being used as a math delimiter

  3. If your blog allows you to enter raw HTML, you could use <span>$</span> to prevent MathJax from using the dollar as a delimiter (math can't contain HTML tags, so this dollar will not match up with another one, so won't be used as a delimiter).

  4. Put your code examples inside <pre> or <code> containers, as MathJax (at least by default) doesn't process math within these. Your configuration may have changed that, however, so check the skipTags setting in your configuration.

Any of these should allow you to do what you need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top