The way I currently do it is $x \not | y$, which looks awful. There's got to be something better available.
Asked
Active
Viewed 5.0k times
50
Charles Stewart
- 21,014
- 5
- 65
- 121
Qiaochu Yuan
- 849
5 Answers
63
An alternative to \nmid is to use the \centernot command from the centernot package. The resulting \centernot\mid symbol aligns perfectly with \mid and has a more pronounced slash than \nmid:

(On the right, the image shows how the commands behave in sub/superscript.)
lockstep
- 250,273
Philippe Goutet
- 28,978
60
$x\nmid y$ saves the day.
Harald Hanche-Olsen
- 15,968
-
Thanks, Harald! For some reason I thought I had tried this already. – Qiaochu Yuan Oct 23 '10 at 22:40
-
5Remember that
\nmidis not defined inamsmath.amssymbis required for\nmid. – 4ae1e1 Nov 07 '13 at 20:14
29
Another good looking (best to me) and easy option is to use the command \notdivides from the mathabx package. The code
\documentclass{article}
\usepackage{mathabx}
\begin{document}
\[ \prod_{a \notdivides b}^{a \notdivides b} a \notdivides b \]
\end{document}
creates the output

The negating line is longer than \nmid's but shorter than \centernot's.
6
$x \bmod y \ne 0$ ;)
Or, as is more commonly written in mathematics: $x \not\equiv 0 \pmod y$ or $x \ne 0 \pmod y$.
Emil Jeřábek
- 478
-
7That's a programmer's answer. Mathematicians would probably write it $x \neq 0 (\mathrm{mod} y)$ – Phil Miller Oct 25 '10 at 02:53
-
2We'd both be wrong in an algebraist's eyes because a congruence is technically in order:
$x \ncong 0 \left( \mathrm{mod} y\right)$. Thanks for pointing that out. – everybodyelse Oct 25 '10 at 04:34 -
9The TeXnically correct way to do either of those is
$x \ncong 0 \pmod{y}:) – Ryan Reich Nov 21 '10 at 08:59 -
To get the spacing right, the mod binary operator needs to be written as
\bmod, not\mod(the latter is part of the congruence notationa\equiv b\mod c, which is more commonly seen with parentheses). Also, modular congruences are written with\equiv, not\cong(the latter is completely inappropriate in this context; it denotes the geometrical notion of congruence). – Emil Jeřábek May 04 '21 at 11:11
texdoc symbols? – Jukka Suomela Oct 23 '10 at 22:22