For a variable-sized bar denoting "a divides b", I normally use \divides
\newcommand{\zerodel}{.\kern-\nulldelimiterspace} %removes extraneous spacing after \right etc.
\newcommand{\divides}[2]{\left\zerodel#1\ \middle|\ #2\right\zerodel}.
This yields a division bar |
which scales well with arguments both for inline math and displaymode. It also has proper spacing. Here is an example (see left-hand or top picture):
left-hand (or top) picture
\divides
right-hand (or bottom) picture
\notdiv
How could one define a similary-behaving vertical line for "a does not divide b"? The command \nmid
is commonly used but does not scale with arguments.
- There are many related questions on TeX.SE (e.g., 1, 2, 3, 4, 5), however the variable scaling has not been incorporated, or negated divisibility is not covered.
I tried the following non-working options
%\newcommand{\notdiv}[2]{\left\zerodel#1\ \middle\nmid\ #2\right\zerodel} %does not work
\newcommand{\notdiv}[2]{\left\zerodel#1\ \nmid\ #2\right\zerodel} % also does not work (image with this)
which gave the right-hand (or bottom) picture.
As we can see, \notdiv
does not scale with the arguments.
- Question: What would be a good way to go about this?
Note: the hope is to scale only the vertical bar, not the slanted line.
Here is the MWE which was also used to generate the images.
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\newcommand{\zerodel}{.\kern-\nulldelimiterspace} %removes extraneous spacing after \right etc.
\newcommand{\divides}[2]{\left\zerodel#1\ \middle|\ #2\right\zerodel}
%modify \notdiv as you see fit
%\newcommand{\notdiv}[2]{\left\zerodel#1 \middle\nmid #2\right\zerodel} %does not work
\newcommand{\notdiv}[2]{\left\zerodel#1\nmid#2\right\zerodel} %does not work
\begin{document}
\centering
inline: $\divides{c}{d}$, $\divides{\dfrac{a}{b}}{c}$
\[\divides{c}{d}\]
\[\divides{\frac{a}{b}}{c}\]
inline: $\notdiv{c}{d}$, $\notdiv{\dfrac{a}{b}}{c}$
\[\notdiv{c}{d}\]
\[\notdiv{\frac{a}{b}}{c}\]
\end{document}