Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 10 down vote accepted

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{-}}

instead.

share|improve this answer
    
Thanks! This works perfectly. I already tried \let\setminus\smallsetminus, but I didn't know that it was overwritten. –  Semafoor May 10 '12 at 2:48
add comment

Your Answer

 
discard

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.