# Symbol for exact division

Among many symbols which can be used for the expression "a divides b'', the preferred one is \mid (and its brother \nmid) which has some spacing advantage over \vert. But the double-bar for "a divides exactly b" is normally rendered by \Vert, which has the same spacing problems as \vert. Is there a "double version" of \mid?

• What's the difference between “divides” and “divides exactly”? – egreg Nov 4 '15 at 11:41
• @egreg: Perhaps exactly →there's no remainder? Just a guess – user31729 Nov 4 '15 at 11:44
• For me, "a divides exactly b" means that a divides b but the greatest common divisor between a and b/a is 1. This applies particularly well for prime-powers: 3 divides 45, 9 divides 45, 27 does not, so I would write that 3 divides 45 and 9 divides 45 exactly. – Filippo Alberto Edoardo Nov 4 '15 at 11:45
• although the name is not even close, \nparallel from amsfonts is the proper class as well as the proper shape. – barbara beeton Nov 4 '15 at 14:02

I'd use more semantic names, say \dv for “divides” and \edv for “exactly divides”. The first is easy

\newcommand{\dv}{\mid}


For the second, we can do

\newcommand{\edv}{\mathrel\Vert}


Full example:

\documentclass{article}

\newcommand{\dv}{\mid}
\newcommand{\edv}{\mathrel\Vert}

\begin{document}

$3\dv 45$ and $9\edv 45$

\end{document}


There is no \nedv, though. We can build it using picture mode. There is \nparallel, but it's slightly different.

\documentclass{article}
\usepackage{amssymb,pict2e}

\newcommand{\dv}{\mid}
\newcommand{\ndv}{\nmid}
\newcommand{\edv}{\mathrel\Vert}

\makeatletter
\newcommand{\nedv}{\mathrel{\mathpalette\nedv@\relax}}
\newcommand{\nedv@}[2]{%
\sbox\z@{$\m@th#1|$}%
\setlength{\unitlength}{\dimexpr\ht\z@+\dp\z@}%
\vcenter{\hbox{%
\begin{picture}(0.5,1)
\roundcap
\put(0.15,0){\line(0,1){1}}
\put(0.35,0){\line(0,1){1}}
\put(0,0.4){\line(1,1){0.5}}
\end{picture}%
}}%
}
\makeatother

\begin{document}

$3\dv 45$ and $9\edv 45$

$10\ndv 45$ and $3\nedv 45$

$\edv$

$\mid$ $\nmid$ $\nedv$ $\nparallel$
\end{document}


The last line has a visual comparison between \mid (alias \dv), \nmid (alias \ndv), \nedv and \nparallel. If you think that \nparallel suits you, then

\newcommand{\nedv}{\nparallel}


is sufficient.

• Great Figaro-etish answer and very presto indeed! I'm of course going to accept this, just one more question: can you explain the role of \mathrel (at least for the non-negated one)? Thanks. – Filippo Alberto Edoardo Nov 4 '15 at 12:19
• @FilippoAlbertoEdoardo The difference between | and \mid is that the latter is essentially \mathrel{|}, which affects the spacing, giving it the same role as = or \leq. – egreg Nov 4 '15 at 12:22
• Yes, this I knew, I ignored the command \mathrel{|}. I guess it defines the variable as being a relation instead of something else, right? Whence de -rel in the name of the command... – Filippo Alberto Edoardo Nov 4 '15 at 12:29
• the negation slash looks a bit high to me. by the way, what about \nparallel from 'amssymb (amsfonts)? why would that not be suitable? (even if the name is way off.) – barbara beeton Nov 4 '15 at 14:01
• @barbarabeeton Of course I forgot about \nparallel! On the other hand, the slash on \nmid` is not in the geometric center of the bar, but a bit higher. It's debatable what to do for negating the double bar. – egreg Nov 4 '15 at 15:38