Absolute Value in LaTeX
For a simple absolute value type the bars: |x|. amsmath’s \lvert x \rvert is the cleaner form because LaTeX then knows which bar opens and which closes. For tall contents use \left| \frac{a}{b} \right|, and write a norm with double bars: \lVert v \rVert.
Absolute value and norm
|x|Quickest form; fine for simple cases.
\lvert x \rvertOpening and closing bars with correct spacing (amsmath).
\left| \frac{a}{b} \right|Bars that grow with the contents.
\bigl| x \bigr|One size larger, chosen by hand (also \Bigl, \biggl).
\lVert v \rVertNorm with double bars (amsmath).
\|v\|Short form of the double bars.
\left\lVert \mathbf{v} \right\rVert_2Stretching norm with a subscript.
- Text mode, no math preview
\abs{x}Your own macro after
\DeclarePairedDelimiter\abs{\lvert}{\rvert}(mathtools).
Try it live
Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.
Absolute value examples
Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.
Definition
LaTeX|x| = \begin{cases} x & x \ge 0 \\ -x & x < 0 \end{cases}Triangle inequality
LaTeX\lvert a + b \rvert \le \lvert a \rvert + \lvert b \rvertAbsolute value of a fraction
LaTeX\left| \frac{x - \mu}{\sigma} \right| < 2Complex modulus
LaTeX\lvert z \rvert = \sqrt{a^2 + b^2}Euclidean norm
LaTeX\lVert \mathbf{x} \rVert_2 = \sqrt{\sum_{i=1}^{n} x_i^2}Hand-sized bars
LaTeX\Bigl| \sum_{i} a_i \Bigr| \le \sum_{i} |a_i|\Bigland\Bigrpick a fixed size; handy when\left … \rightmakes the bars too tall.Determinant bars
LaTeX\det A = \lvert A \rvert
Why \lvert and \rvert instead of |
The keyboard | is one symbol for both sides, so in expressions like |-x| LaTeX may space the minus sign as a binary operator. \lvert and \rvert (from amsmath) mark the opening and closing bar, which fixes the spacing.
Neither form grows by itself. \left| … \right| stretches the bars to the height of the contents; the fixed sizes \bigl|, \Bigl|, \biggl| give you control when automatic sizing looks too large.
An \abs macro with mathtools
In Overleaf you can define paired delimiters once and reuse them. \abs{x} gives normal bars, \abs*{…} makes them stretch, and \abs[\big]{…} picks a size. The same works for norms.
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
% ...
\[ \abs*{\frac{a}{b}} \le \norm{x} \]Common mistakes
Plain bars stay one line tall and look too short next to a fraction.
Instead of|\frac{a}{b}|Write\left| \frac{a}{b} \right|Two single bars are spaced apart;
\lVert … \rVert(or\|v\|) draws a proper double bar.Instead of||v||Write\lVert v \rVertEvery
\leftneeds a matching\rightwith a delimiter; use\right.for an invisible one.Instead of\left| x \right (missing the second bar)Write\left| x \right|
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
|x|,\left| \right|and\|work anywhere.\lvert,\rvert,\lVert,\rVertand\biglneed amsmath;\DeclarePairedDelimiterneeds mathtools.MathJax and KaTeX
MathJax and KaTeX support
\lvert,\rvert,\lVert,\rVert,\left| \right|and the\bigsizes. In Markdown tables a bare|can split the table cell, so\lvert … \rvertis also the safer choice there.Microsoft Word
Word has bracket templates for bars, but pasted LaTeX is not converted reliably. Write the expression here and use Copy for Word to paste an editable equation.
Absolute value in LaTeX: questions
- How do I write absolute value in LaTeX?
- Use
|x|for simple cases or\lvert x \rvertwith amsmath. For fractions and other tall contents use\left| … \right|. - How do I make absolute value bars bigger?
- Let them grow with
\left| … \right|, or pick a size with\bigl| … \bigr|,\Bigl| … \Bigr|or\biggl| … \biggr|. - How do I write a norm with double bars?
- Use
\lVert x \rVert(amsmath) or\|x\|. Add a subscript after the closing bar for the kind of norm:\lVert x \rVert_2. - Why does my absolute value break a Markdown table?
- Markdown uses
|to separate table cells. Write the bars as\lvertand\rvertinside tables.
Related LaTeX reference
- Floor Function in LaTeX\lfloor x \rfloor and \lceil x \rceil, stretching them with \left and \right, and \floor / \ceil macros with mathtools.
- Vector in LaTeX\vec{v} and \overrightarrow{AB}, bold vectors with \mathbf and \boldsymbol, unit vectors, column and row vectors, and norms.
- Greater Than or Equal to in LaTeXGreater than or equal to (\geq), less than or equal to (\leq), plain < and >, much less than, slanted and negated forms.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
Have the formula as a picture?
Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.
Convert an image to LaTeX