I want to write something basic like "10 $US" but sometimes it makes the text look weird. It changes the font and writes italic text. And sometimes it will insert a newline. For example in my answer for this question.

How can I safely insert a dollar sign?

  • 1
    For reference: the list of MathJax-enabled sites. A couple of them use \$ as formula delimiters, so on those sites the lone $ will render normally. But on most, $ is a MathJax delimiter.
    – user259867
    Aug 9, 2015 at 3:35
  • [backslash] [dollar sign]
    – Mazura
    Jun 21, 2018 at 2:21

4 Answers 4


Many Stack Exchange sites which involve a strong use of mathematics will have MathJax enabled for easily creating mathematical formulas. This script uses the dollar sign as a beginning and ending delimiter, so you will have to escape them like so: \$

  • This doesn't work for me. Any pointers where I can look? Yes I have MathJax and I use githubpages. It really messes up the content. So I use $ every time but it looks ugly as hell.
    – Pandian Le
    Jun 1, 2020 at 6:41

On a site where math mode is available by using a dollar sign—as well as on a site where math mode is not available—you can write a range of five to ten dollars by escaping each dollar sign with a backslash (\$5-\$10). You will see the symbols that you intended.

  • Result on this site: $5-$10

However, on a site where math mode is available by using a dollar sign, if you don't use a backslash before each dollar sign ($5-$10), you see the sequence five, dash, one, zero. The five and the dash get formatted in math mode.

  • Result on this site: $5-$10

Recall that, when expressing a numeric range, you may wish to use a typographic en dash, rather than a hyphen-minus character. One way to specify that is an XML-style character reference (\$5–\$10).

  • Result on this site: $5–$10

On a site where math mode is available by using a dollar sign, by accidentally using the XML-style character reference in math mode $5–$10, you would produce an error.

  • Result on this site: $5–$10

We can clarify what's happening, by investigating a little further. Spoiler: We won't find useful techniques in this direction.

Recall that, in math mode, there is an escape command (\text{xyz}). Escaped text in math mode will be formatted as text.

  • Result on this site: $\text{xyz}$

Escaped text in math mode clearly has an appearance that is clearly different from formatting as mathematics, the formatting that occurs when the escape command is not used ($xyz$). When formatted as mathematics, letters display in italics. They are spaced differently from letters as text.

  • Result on this site: $xyz$

Inside that escape command, neither LaTeX syntax for the en dash (--) nor XML-style syntax for the en dash (–) will be understood. If you try them ($5\text{--7–}$10), those constructs will be treated only as text character data inside math mode.

  • Result on this site: $5\text{--7–}$10
  • The simplest way to write an en-dash is to just include it directly as a Unicode character without any encoding. This works even inside MathJax. Aug 12, 2020 at 6:00

In markdown editors such as GitHub, or Jupyter notebook, with MathJax available, you can use double backslash and a dollar sign together to show any amount or range of amount in the dollar.

Note that, in StackExchange or any StackOverflow related site, a single backslash is enough. So I couldn't show you the double backslash, because this editor refuse to show double backslash together.

  • FYI, to show a literal double backslash in a Stack answer, persist -- use four backslashes to get two: \\\\. ("Comments" work differently than "Answers", however!)
    – Drew
    Nov 20, 2023 at 17:32

`$` - code insertion worked for me in something like MathJax. Just \$ was printed as is.

  • 1
    The source of the [now-fixed] linked answer shows that just \$ works perfectly. Dec 26, 2019 at 1:01
  • I just suggested the one method that suits me. Maybe someone will work on the same system, which works weirdly with \ $, as in my situation Dec 27, 2019 at 8:38
  • Well that worked for me. My markdown linter was escaping my dollar signs in an auto-save feature in some situations (maybe one's it thought were part of an equation? I couldn't really get rhyme or reason) and then my markdown to html converting was treating the slash as simply text, which I think it should have. So I was stuck (short of figuring out my auto-save issue). Wrapping it in code markings was just the trick I needed for this. Cheers. Oct 15, 2020 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .