# Remapping LaTeX symbol to another unicode value

When compiling the following piece of LaTeX code, the ∖ symbol does not show up.

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Latin Modern Roman}
\setmathfont{Latin Modern Math}
\begin{document}
This will not show: $\setminus$ \\
This will show: $\smallsetminus$
\end{document}


I know why this happens: \setminus translates to unicode character 0x29F5, and this character is not part of Latin Modern Math. What I would like to do is to use Unicode character for \smallsetminus, 0x2216, instead. So what I am really looking for is a way to remap the \smallsetminus command to another Unicode value than the one defined by the unicode-math package. I know a possible way to get a value for \setminus would be to use another math font that does have Unicode character 0x29F5. Adding the line

\setmathfont[range={"29F5}]{XITS Math}


gives me a ∖ symbol, but I don’t want to use another font for this character.

-

The following makes \setminus equivalent to \smallsetminus:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\AtBeginDocument{\let\setminus\smallsetminus}

\begin{document}
$A \setminus B \qquad A \smallsetminus B$
\end{document}


The \AtBeginDocument is necessary because unicode-math defines its commands only at \begin{document}. So a simple \let\setminus\smallsetminus in the preamble would get overwritten. Alternatively, you could put \let\setminus\smallsetminus after \begin{document}, but this is a less “clean” solution as it violates the separation of content and styling.

If you want to use a completely different symbol, you can do something like

\AtBeginDocument{\def\setminus{-}}