Is there any difference in usage of the mentioned commands? I ask it because, for example, it's known that for functions it's more preferable (and more correct) to use \colon
instead of usual :
.
2 Answers
In the Computer Modern math font family, the shapes of \setminus
and \backslash
are identical. (Aside: the vertical size of \backslash
can be modified by \left
and \right
directives; that's not the case for \setminus
.) That does not mean, though, that the symbols get typeset identically. This is because \backslash
has status mathord
("math ordinary"), whereas \setminus
has status mathbin ("math binary operators"). Having status mathbin
means that in combinations of mathord-mathbin-mathord -- as in U\setminus V
-- a "medspace" amount of whitespace gets inserted on both sides of the \setminus
symbol.
In contrast, TeX does not insert whitespace between math atoms (to use a TeX jargon word) of status mathord
. Hence, no extra whitespace is inserted in U\backslash V
.
Finally, mainly for the sake of completeness, it's worth mentioning the existence of the macro \smallsetminus
, which is provided by the amssymb
package. As one can tell from the final row of the following table, \smallsetminus
looks rather different from \setminus
, doesn't it?
\documentclass{article}
\usepackage{xcolor,array,booktabs,amssymb}
\begin{document}
\begin{tabular}{@{} >{$}l<{$} l @{}}
$Result$ & LaTeX code \\
\midrule
\setminus\mkern-9mu\color{red}\backslash & \verb+\setminus\mkern-9mu\color{red}\backslash+ \\
\addlinespace
B\setminus D & \verb+B\setminus D+ \\
B\mathbin{\setminus}D & \verb+B\mathbin{\setminus}D+ \\
B\:{\setminus}\:D & \verb+B\:{\setminus}\:D+ \\
B\mkern4mu{\setminus}\mkern4mu D & \verb+B\mkern4mu{\setminus}\mkern4mu D+ \\
\addlinespace
B{\setminus}D & \verb+B{\setminus}D+ \\
B\backslash D & \verb+B\backslash D+ \\
\addlinespace
B\smallsetminus D & \verb+B\smallsetminus D+
\end{tabular}
\end{document}
-
1See my comment under the question:-) (but you could add ams \smallsetminus Commented May 19, 2020 at 19:28
In unicode-math
, \backslash
is \ (U+005C) , \setminus
is ⧵ (U+29F5) and \smallsetminus
is ∖ (U+2216). Also, \xbsol
is ⧹ (U+29F9).
This is especially noticeable when using the default font, Latin Modern Math, which lacks \setminus
. New Computer Modern Math fixes this bug.