TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a set subtraction operation in an AMS formatted template. In the end, what I want should look like A\B. But I'm doing this in math-mode $A\B$ and this gives me errors. I've also tried using the \diagdown symbol, but it doesn't work either. Is there another way to do this?

share|improve this question
Remember that \ is TeX escape character, so TeX is seeing \B as a macro name (probably undefined). What about $A\backslash B$? – JLDiaz Dec 9 '12 at 18:33
For your special Problem, @corentin already gave the answer below. For a more geneal answer, see tex.stackexchange.com/q/9363/18674 – Benedikt Bauer Dec 9 '12 at 18:33
up vote 32 down vote accepted

\setminus should be what you are after.

\usepackage{amssymb} % for \smallsetminus

\[ \mbox{setminus: } A \setminus B,\quad \mbox{smallsetminus: } A \smallsetminus B, \quad \mbox{backslash: } A \backslash B\]

enter image description here

Note that you can find more information here on How to look up a symbol?. In particular, you have the Comprehensive LaTeX symbols and the website Detexify. There is also this post which was mentioned earlier in a comment

share|improve this answer
You can include also $\backslash$, which produces a different spacing, for comparison. – JLDiaz Dec 9 '12 at 18:35
@JLDiaz Thanks for your comment, you are right, I will update my post. – Corentin Dec 9 '12 at 18:37
there is also \smallsetminus, available with \usepackage{amssymb}, for those who prefer a smaller symbol (with the same meaning). – barbara beeton Dec 9 '12 at 18:38
@barbarabeeton Thanks, answer updated! – Corentin Dec 9 '12 at 18:46
This was exactly what I was looking for. Thanks! :) – Paul Dec 9 '12 at 19:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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