5

How can we insert the \ symbol in math mode for LaTeX and MathJax without loading any package that is required to achieve this symbol?

I tried

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$\$
\end{document}

but the program gives errors, also with ${\}$, \text{\} etc. fails. In MathJax I use $\$ and it produces error.

The context of the problem is I want to represent the (missing) \ symbol inside a formula (not in SE). The solution is add that symbol, so I want to alert the user "Hey, you forgot to add $\$ in ${1,2,3}$. It should be $\{1,2,3\}$" (of course the site does not have single quotes (`)).

Thanks!!

closed as off-topic by user36296, Mensch, gusbrs, Troy, Circumscribe Jan 1 at 11:10

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center." – user36296, Mensch, gusbrs, Troy, Circumscribe
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Try \textbackslash in text mode. But what do you need that symbol for? – siracusa Nov 30 '18 at 4:00
  • 4
    \backslash in math mode. – CarLaTeX Nov 30 '18 at 4:00
  • 4
    “without loading any package” But you are loading amsmath! – Henri Menke Nov 30 '18 at 4:45
  • 3
    Reading your comment to Henri's answer, I think it would be better to add to your question why you want to use a backslash character in math mode. Displaying escaped braces in math mode seems really uncommon to me, so perhaps there is a completely different but better solution to your actual problem (I suspect it has to do with displaying source code) – siracusa Nov 30 '18 at 5:21
  • 2
    @manooooh I would use a code block in HTML (or whatever output format you're using): anything except a LaTeX/MathJax formula (because you want to show the literal raw text that is to be input, not the result of treating it as a formula). – ShreevatsaR Nov 30 '18 at 7:19
9

You probably want to use the backslash to exclude elements from a set. To this end use \setminus. To get the set of all integers without zero, you'd write

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
$\mathbb{Z} \setminus \{ 0 \}$
\end{document}

enter image description here

Also works in MathJax. Live example: http://mathb.in/29559

  • I was aware of \setminus. As I said in comments, the symbol is for represent the \ required to write braces (here \{\}) but I wanted to display it in math mode, so I think the appropiate symbol is \backslash. – manooooh Nov 30 '18 at 5:01
  • 3
    @manooooh - You wrote, "I think the appropriate symbol is \backslash". That's not quite right, since \setminus has math type "mathbin" ("binary operator"), whereas \backslash has math type "mathord" ("ordinary"). In order to get the typographically proper amount of spacing around the backslash character, what you would need to write is \mathbin{\backslash}. – Mico Nov 30 '18 at 6:36
2

I often prefer to use \smallsetminus because the slash is lower down.

In this link http://docs.mathjax.org/en/latest/tex.html. I have seen that there is a possibility of using it with MathJax.

enter image description here

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
$\mathbb{R}\smallsetminus\{0\}$
\end{document}

enter image description here

  • 1
    \smallsetminus is a good option, too! – manooooh Dec 31 '18 at 21:54
  • 1
    @manooooh Than you very much and I wish you a prosper a good new year. – Sebastiano Dec 31 '18 at 21:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.