[Tex/LaTex] Symbol for exact division

symbols

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?

Te result of using \vert, \mid and \Vert

Best Answer

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}

enter image description here

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.

enter image description here