# 'Not element of' in Latin Modern

In the following example, the ∉ symbol does not look good.

\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Latin Modern Roman}
\setmathfont{Latin Modern Math}
\begin{document}
This does not show: $\notin$ \\
This does not look good: $\not\in$
\end{document}


\not\in works when not loading unicode-math, but unicode-math somehow prevents it from working (?). The Unicode character 0x2209 does not seem to be included in the Latin Modern Math font. I know that I can load the Unicode character from another font, but I just want the output to look like \not\in in Computer Modern.

edit: To clarify, I just want the output to look like \not\in without using unicode-math. I want to use unicode-math for reasons not visible in this example.

-

After last Khaled's comment, here's something that seems to work

\Umathchardef\xnot="3 \symoperators "0338
\AtBeginDocument{
\renewcommand\not[1]{#1\xnot}
\renewcommand{\notin}{\not\in}
}


Then

$a\not\in b \notin c$


will work (although the placement doesn't seem to be optimal).

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

\Umathchardef\xnot="3 \symoperators "0338
\AtBeginDocument{\renewcommand\not[1]{#1\xnot}
\renewcommand{\notin}{\in\xnot}}

\begin{document}

$a \not\in S_{\not\in}$

$a\in\xnot b \notin c$

$a\in b \in c$

\end{document}


A possible improvement is to say

\Umathchardef\xnot="3 \symoperators "0338
\AtBeginDocument{
\renewcommand\not[1]{#1\mathrel{\mkern1mu}\xnot}
\renewcommand{\notin}{\not\in}
}


that pushes the slash slightly to the right, so that the upper end is lined up with the terminators of the \in symbol.

Note: this definitely doesn't work with XITS Math or Asana Math, which, however, have the proper symbol.

## UPDATE

As of January 2013, the problem seems to be solved; here's the minimal example:

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

\begin{document}

$a \not\in S_{\not\in}$

$a \notin S_{\notin}$

\end{document}


Both LuaLaTeX and XeLaTeX give the correct result.

-
I once considered something like that, but it does not look that good with XITS and Cambria, not sure if unicode-math should do that by default or not. –  Khaled Hosny May 10 '12 at 10:30
@KhaledHosny I guess not too; just a hack for the missing symbol in Latin Modern Math. I'm trying to fix the spacing. –  egreg May 10 '12 at 11:29
This works perfectly and fixes my problem! Do you think you could briefly explain the \Umathchardef command? Google is not a big help. I suppose you use it to define a command (\xnot) to correspond to a Unicode character (0x338), but I don't know what the "3 and \symoperators are for, or what the different options are here. –  Semafoor May 10 '12 at 17:01
@Semafoor It's XeTeX and LuaTeX lingo for defining a relation symbol ("3), from math font \symoperators and position "338. –  egreg May 10 '12 at 18:46
\documentclass{article}
\usepackage{unicode-math}
\setmainfont{Latin Modern Roman}
\setmathfont{Latin Modern Math}
\newcommand\cnot[1]{%
\mathrel{\ooalign{\hfil$#1$\hfil\cr\hfil$/$\hfil\cr}}}

\begin{document}

$a \cnot\in S$

\end{document}


Note: I don't know why Oberdiek's centernot package also fail. So I had to implement one myself.

Edit:

To make the macro to change size automatically as egreg suggested,

\def\cnot#1{\mathrel{\mathpalette\ccnot{#1}}}
\def\ccnot#1#2{\ooalign{\hfil$#1#2$\hfil\cr\hfil$#1/$\hfil\cr}} % helper macro

-
It seems that unicode-math's \not is really badly implemented, all my math fonts cannot typeset \not\in properly. –  Leo Liu May 10 '12 at 5:59
@egrep: \not is zero width in most Unicode fonts too, I think the problem is because it is defined as a math accent not a relation symbol in unicode-math. –  Khaled Hosny May 10 '12 at 8:31
@LeoLiu Would you implement it with \mathpalette so that the symbol changes size in subscripts and superscripts? –  egreg May 10 '12 at 9:07
@egreg: not so mysterious, it is a combining mark in Unicode, so that is the logical choice, it should then be handled by the engine (I had a patch for luatex, but had to hold it back because accents break math spacing rules, I'm yet to find a sane solution for this). But it makes little difference, defining it as mathrel does not help a bit, because of the way it is designed in all fonts, try \Umathchardef\not="3 \symoperators "0338 yourself. –  Khaled Hosny May 10 '12 at 9:25
@egreg, it prints here, but look closely, it will be shifted to the left away of the symbol. It doesn't combine because the engines don't handle it correctly, the old TeX approach doesn't work here because it was a CM specific Knuthian hack. –  Khaled Hosny May 10 '12 at 10:04

Try \centernot\in (from the centernot package): It centers the / above whatever symbol follows.

-