# How can I nicely show an absolute value with the “divides” function, |?

Right now, I am using \lvert,\rvert, and \mid to display

\documentclass[border=3pt]{standalone}
\usepackage{amsmath}
\begin{document}
$\lvert x \rvert \mid y$
\end{document}


Is there a better way to do this?

-
Interesting issue. You could slight change the height of the divides with something like \newcommand{\Divides}{\mathbin{\big|}}, and then use $\lvert x \rvert \Divides y$. –  Peter Grill Feb 11 '13 at 1:10
I think this notation is possibly very confusing. Why not define an new math operator: \DeclareMathOperator{\abs}{abs} so you would then write $\abs(x) \mid y$ –  A.Ellett Feb 11 '13 at 1:49
@A.Ellett You make a valid point. However, it would mean changing throughout the document just to satisfy one occurrence. –  beethree Feb 11 '13 at 2:21
If the numbers are integer, x\mid y says exactly the same thing. –  egreg Feb 11 '13 at 9:31
@egreg yay math! Although I can see how, as a learning student, it could confuse someone (if it were a textbook we were talking about, for example). –  Sean Allred Feb 11 '13 at 9:36

## Option 1

By making the \mid bigger (based on the given comments),

\documentclass[border=3pt]{standalone}
\usepackage{amsmath}
\newcommand\abs[1]{\ensuremath{\lvert#1\rvert}}
\newcommand\divides{\ensuremath{\bigm|}}
\begin{document}
$\abs{x} \divides y$
\end{document}


## Option 2

By making the font smaller locally, {\scriptstyle\lvert#1\rvert},

\documentclass[border=3pt]{standalone}
\usepackage{amsmath}
\newcommand\abs[1]{\ensuremath{{\scriptstyle\lvert#1\rvert}}}
\begin{document}
$\abs{x} \mid y$
\end{document}


## Option 3

Rephrasing the mathematical statement,

\documentclass[border=3pt]{standalone}
\usepackage{amsmath}
\newcommand\abs[1]{\ensuremath{\lvert#1\rvert}}
\begin{document}
$y \mod \abs{x} = 0$
\end{document}

-
The fact that x is made smaller than y makes this look off, IMO –  Matthew Leingang Feb 11 '13 at 1:41
Instead of renaming \mid (first case) I would create a new command \newcommand{\divides}{\bigm|}, where \bigm automatically provides the spacing you are looking for. –  Manuel Feb 11 '13 at 2:09
I will make the \mid bigger. –  beethree Feb 11 '13 at 2:21
If only you removed those useless \ensuremath commands… –  egreg Feb 11 '13 at 9:30
@egreg: It can be regarded as a best practice. :-) –  cyanide-based food Feb 11 '13 at 9:32

I think this notation is possibly very confusing. Why not define an new math operator:

\DeclareMathOperator{\abs}{abs}


so you would then write

$\abs(x) \mid y$


-

Yes, it looks too similar to \mid. The best solution I've been able to come up is to reorganize and avoid such constructions (whatever you do, it will look confusing), probably by spelling it out: ... $$\abs{x}$$ divides $$y$$...

-
This is immensly better than all the alternatives. –  Mariano Suárez-Alvarez Feb 11 '13 at 3:58
Come to think about it, what makes \abs{x} dividing y any different from x dividing y? (OK, yes, I've had such constructions, but there the abs{} meant size/order of a group/...) –  vonbrand Feb 11 '13 at 4:05

I have recently been lecturing on the Sylow theorems and related topics, which means that I am continually needing to say that the size of some group divides or is divisible by something. The solution I have adopted is to denote the size of a finite set by \#(G), not |G|.

-