# \mid, | (vertical bar), \vert, \lvert, \rvert, \divides

What's the difference between the different vertical bars?

$S = \{\, x \mid x \not= 17 \,\}$
$a \vert b$ implies $a \leq b$ when $b \ne 0$
$a|b$ implies $a \leq b$ when $b \ne 0$
$\lvert x \rvert$ is always non-negative


Are all of these uses correct?

• (Off-topic) Actually, 1|0 but 1 > 0. Commented Jul 28, 2010 at 18:06
• Yeah, well… it's true if a, b > 0. Commented Jul 28, 2010 at 18:09
• Divides is actually defined on negative numbers as well; 2 | -10. @Ben Alpert had the right condition. Of course, that's off topic from the question. As far as that's concerned, I'm glad you asked! The answers have been rather helpful. Commented Sep 4, 2011 at 21:58
• \mid automatically has spacing before and after it, which | does not have. Commented May 3, 2013 at 0:08
• I ended up using \bigg|, which unlike other solutions provided so far, scales.
– user75494
Commented Apr 2, 2015 at 20:10

According to texdoc symbols:

\mvert and \mid are identical and produce a relation. \vert is a synonym for | and both produce the same symbol, but should be used in the context of an ordinal, and should be used as an operator, not as a delimiter (p54, bottom). \divides once again produces the same symbol but should be used as a binary “divides” operator.

\lvert and \rvert are left and right delimiters, respectively.

• I am now thoroughly confused – what is an ordinal? Commented Jun 9, 2011 at 19:30
• @Ben The word “ordinal” in this context is copied from the symbols document which uses it without explanation. My guess is that it’s the usual sense: to denote a number symbol (operand) rather than an operator or a delimiter. I can’t think of a use for this, but the very similar symbol “‖” is used as an ordinal in standard typography, namely as the fifth footnote symbol. The consequence for LaTeX is spacing: | doesn’t introduce any. Commented Jun 9, 2011 at 20:26
• So when using a vertical bar as a separator in a set definition before the condition, is that a relation or an operator? I'd say it's a delimiter, but those are left or right only, not centre. Correct? Commented Dec 16, 2013 at 2:30
• @Christian Good question. A bit of both, I’d say. No idea what’d be appropriate here. Probably \mid / \mvert. Commented Dec 16, 2013 at 8:03
• An FYI for those who want to use these symbols: \mvert and \divides require the MnSymbol package; \lvert and \rvert require amsmath or MnSymbol. Commented Nov 24, 2014 at 23:35

Another option which was not mentioned in any of the comments above is:

F=\left.\frac{\partial f}{\partial x}\right|_{\hat x_{k-1}}


I hope this helps someone else.

• Been searching for this answer for way too long, should be higher on the list! Commented Sep 27, 2022 at 14:45
• Thank you very much. Commented Dec 18, 2022 at 18:15

This is similar in spirit to qbi's answer. Let me quote from the guide to the amsmath package (the document known as amsldoc), section 4.14.2 Vertical bar notations:

The amsmath package provides commands \lvert, \rvert, \lVert, \rVert (compare \langle, \rangle) to address the problem of overloading for the vert bar character |. This character is currently used in LaTeX documents to represent a wide variety of mathematical objects [...]. The multiplicity of uses in itself is not so bad; what is bad, however, is that fact that not all of the uses take the same typographical treatment, and that the complex discriminatory powers of a knowledgeable reader cannot be replicated in computer processing of mathematical documents. It is recommended therefore that there should be a one-to-one correspondence in any given document between the vert bar character | and a selected mathematical notation, and similarly for the double-bar command \|. This immediately rules out the use of | and \| for delimiters, because left and right delimiters are distinct usages that do not relate in the same way to adjacent symbols; recommended practice is therefore to define suitable commands in the document preamble for any paired-delimiter use of vert bar symbols:

\providecommand{\abs}[1]{\lvert#1\rvert} \providecommand{\norm}[1]{\lVert#1\rVert}


whereupon the document would contain \abs{z} to produce |z| and \norm{v} to produce ∥v∥.

• Adding in \left and \right then means that they have a chance of scaling correctly as well. Commented Jul 29, 2010 at 9:40
• @daleif: See tex.stackexchange.com/q/1023/86 for a question about getting the right parenthesis size when the inner text isn't vertically balanced. Commented Apr 11, 2011 at 8:38
• The package mathtools should be used to provide scalable versions of \abs and \norm in this answer. Commented Mar 29, 2018 at 7:51

As far as I know, by default they're all defined to be the same bar, except for maybe some spacing differences. But LaTeX, like properly written HTML, favors semantic markup over purely functional markup - you use the command for what you mean, rather than just what you want to appear on the page. This way, if you decide later on that you want certain kinds of bars to look different, it's easier to change only the bars you actually want to and not mess with anything else. For example, if you want to have less space between the bars and the text in constructions like |x|, you can redefine \lvert and \rvert appropriately.

As qbi said, it is recommended to define a higher level of semantic markup, namely things like \abs, \norm, \union, \or, \suchthat, etc., to represent what you really mean in your formulas, and to use those instead of \vert, \lvert and \rvert directly.

• they're all defined to be the same glyph, but the class is different; check the definitions in plain.tex or appendices b and f of the texbook (via the index). Commented Feb 3, 2012 at 17:46

\mid is a relation symbol and | is a delimiter. As far as I know \vert is basically the same as |. For things like abslute value and norm I like to use mathtools.sty. This class allows to define something like \absval{} which translates to \lvert ...\rvert. This is useful when you tend to forget the closing bar. :-)

• According to symbols, \vert and | aren’t delimiters either. Commented Jul 28, 2010 at 18:42
• You don't need a package like mathtools to define \absval{} as you describe. Commented Aug 20, 2010 at 14:28

Another option is instead of using

\left. ... \right|


one can use

F=\frac{\partial f}{\partial x}\bigg|_{\hat x_{k-1}}


– Community Bot
Commented Feb 28, 2023 at 17:50
• I would have liked to add as a comment to answer above by desmond13, but cannot because of rep. If you think that the answer by desmond13 is inappropriate as well, feel free to delete both. Commented Mar 2, 2023 at 10:43

Old question, but it got bumped to the front page…

The character printed by |, \mid, \lvert and \rvert is always the same, but with different math class:

• | is an ordinary symbol;
• \mid is a relation symbol;
• \lvert is an opening symbol;
• \rvert is a closing symbol.

Access to the last two requires loading amsmath. Except \mid they can all be used in the context of delimiters. For instance, if you need a taller bar as a relation symbol, you can use \bigm|; an example usage could be in

\lvert a\rvert \bigm| b


because \bigm\mid results in an error.

I'd deem a|b to denote divisibility a wrong usage on mathematical grounds, because this is a relation. Personally I always use \mid for this case, but I acknowledge that people might find the spacing excessive.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\divides}{%
\mathrel{%
\nonscript\mspace{-\thickmuskip}%
\nonscript\mspace{0.5\thinmuskip}%
|
\nonscript\mspace{0.5\thinmuskip}%
\nonscript\mspace{-\thickmuskip}%
}%
}

\begin{document}

$a\mid b$ $A_{a\mid b}$ (with \verb+\mid+)

$a\divides b$ $A_{a\divides b}$ (with \verb+\divides+)

\end{document}


The \nonscript bits are for avoiding the spaces (positive or negative) to be inserted when TeX wouldn't.

I'd endorse using a semantic command for divisibility, even if it is just

\newcommand{\divides}{\mid}


because this will allow change one's mind at any time (which is what I do for bigger projects).

A possible improvement is coping with the \big problem above:

\documentclass{article}
\usepackage{amsmath}

\NewDocumentCommand{\divides}{s}{%
\mathrel{%
\nonscript\mspace{-\thickmuskip}%
\nonscript\mspace{0.5\thinmuskip}%
\IfBooleanT{#1}{\big}|
\nonscript\mspace{0.5\thinmuskip}%
\nonscript\mspace{-\thickmuskip}%
}%
}

\begin{document}

$a\mid b$ $A_{a\mid b}$ (with \verb+\mid+)

$a\divides b$ $A_{a\divides b}$ (with \verb+\divides+)

$\lvert a\rvert\divides* b$

\end{document}


I'd not generalize to other sizes, because of the symbol's meaning.

In general | should be avoided for the absolute value: compare

$|-1+x|=|x-1|$

$\lvert -1+x\rvert=\lvert x-1\rvert$


The top one is definitely wrong: since | is ordinary, the minus sign finds two ordinary symbols around it and so it typesets as a binary operatio symbol; with the correct syntax, \lvert is an opening, so the minus sign stays unary as it should.

• The last example is pretty nice! Commented Aug 30 at 16:24

I think it is helpful to compare the definitions of these commands:

%%% From kernel

% \mid
\DeclareMathSymbol{\mid}{\mathrel}{symbols}{"6A}
% | and \vert (the same)
\DeclareMathDelimiter{|}{\mathord}{symbols}{"6A}{largesymbols}{"0C}
\DeclareMathDelimiter{\vert}{\mathord}{symbols}{"6A}{largesymbols}{"0C}
% \| and \Vert (the same)
\DeclareMathDelimiter{\Vert}
{\mathord}{symbols}{"6B}{largesymbols}{"0D}
\DeclareMathDelimiter{\|}
{\mathord}{symbols}{"6B}{largesymbols}{"0D}

%%% From amsmath

% \lvert and \rvert
\DeclareMathDelimiter{\lvert}
{\mathopen}{symbols}{"6A}{largesymbols}{"0C}
\DeclareMathDelimiter{\rvert}
{\mathclose}{symbols}{"6A}{largesymbols}{"0C}
% \lVert and \rVert
\DeclareMathDelimiter{\lVert}
{\mathopen}{symbols}{"6B}{largesymbols}{"0D}
\DeclareMathDelimiter{\rVert}
{\mathclose}{symbols}{"6B}{largesymbols}{"0D}


So we summarize as follows:

Command Type Source Can be used as delimiter?
\mid Relation kernel No
\vert Ordinary kernel Yes
| Ordinary kernel Yes
\Vert Ordinary kernel Yes
\| Ordinary kernel Yes
\lvert Opening amsmath Yes
\rvert Closing amsmath Yes
\lVert Opening amsmath Yes
\rVert Closing amsmath Yes

The \mid is special since it's the only relational symbol here. And we should use it in some cases:

1. In division notation: a\mid b
2. In set representation: \{ x \mid x\neq 0 \}