Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
In short: load amsmath and write absolute value as \lvert x \rvert, not as a bare |x|. For readable source and bars that grow around tall arguments, define an \abs{...} macro, ideally with \DeclarePairedDelimiter from mathtools. This page is for researchers and analysts typesetting equations who want correct spacing and consistent notation.
What it is used for in research
The absolute value |z| of a number is its distance from zero, so |-6| equals 6 and |6| equals 6. In papers it appears in error bounds, residuals, convergence statements and norms of scalars. The vertical bar character is overloaded in mathematics: the amsmath User’s Guide lists divisibility (p|q), absolute value (|z|), the “such that” bar in set notation and the “evaluated at” bar as separate uses of the same keystroke. The same guide notes that | and \| should not be used as delimiters because an opening and a closing bar are distinct usages. It therefore provides dedicated commands, covered below. See also the companion guide on the LaTeX vertical line.
Install or access (official source only)
Both packages are distributed through CTAN, the Comprehensive TeX Archive Network. Their package pages are ctan.org/pkg/amsmath and ctan.org/pkg/mathtools. Load them in the preamble:
\usepackage{amsmath}
\usepackage{mathtools}
The commands \lvert, \rvert, \lVert and \rVert come from amsmath (section 4.14.2, “Vertical bar notations”, of the amsmath User’s Guide v2.1). \DeclarePairedDelimiter comes from mathtools (section 3.6, “Paired delimiters”, of the mathtools manual dated 2024/10/04).
Step-by-step task
Basic absolute value
- Load
amsmathin the preamble. - In math mode, write
\lvert z \rvertto produce |z|.\lvertis the left bar and\rvertthe right bar, the way\langleand\ranglepair up. - For the norm of a vector, write
\lVert v \rVertto produce ‖v‖. This also answers the common question about the norm symbol in LaTeX.
Define an \abs and \norm macro
The amsmath guide recommends defining suitable commands in the document preamble, so that the source says what the notation means:
\providecommand{\abs}[1]{\lvert#1\rvert}
\providecommand{\norm}[1]{\lVert#1\rVert}
The document then contains \abs{z} to produce |z| and \norm{v} to produce ‖v‖. If you later change how absolute values are typeset, you change one definition.
Auto-sizing bars with mathtools
The plain macro above has correct horizontal spacing, but the mathtools manual points out that the vertical spacing is poor when the argument is slightly taller than normal, for example a/b. Wrapping the content in \left…\right or \bigl…\bigr fixes it but means giving up the \abs macro. The manual’s alternative is \DeclarePairedDelimiter, with the syntax \DeclarePairedDelimiter{cmd}{left_delim}{right_delim}:
\DeclarePairedDelimiter\abs{\lvert}{\rvert}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
Put these in the preamble; if you previously used \providecommand for the same names, remove those lines. The resulting macro has three forms:
\abs{x}gives bars at normal size.\abs*{\frac{a}{b}}(starred) precedes the delimiters with\leftand\right, so they size automatically.\abs[\Bigg]{\frac{a}{b}}uses an explicit size command, one of\big,\Big,\biggor\Bigg(the manual notes these are converted to their\bigl/\bigrvariants).
mathtools also offers \DeclarePairedDelimiterX and \DeclarePairedDelimiterXPP for delimiters that need more control; the manual’s example uses the XPP form to build an L2 norm with a subscript 2.
Output and how to read it
All of these produce the same visual symbol, a pair of vertical bars around the argument. The difference is in spacing and meaning. A bare |x| treats both bars identically; \lvert x \rvert tells LaTeX the first is an opening delimiter and the second a closing one, which is the point of the amsmath design. Compare outputs on tall content such as a fraction: a fixed-size bar visibly under-covers a/b, while \abs*{\frac{a}{b}} and \abs[\Bigg]{\frac{a}{b}} scale to it.
The amsmath guide also shows explicit sizing inside a larger expression, for example \biggl[\sum_i a_i\Bigl\lvert\sum_j x_{ij}\Bigr\rvert^p\biggr]^{1/p}, where the inner bars are one size step smaller than the outer brackets.
Troubleshooting
- Undefined control sequence on
\lvertor\rvert: these are amsmath commands, so check that\usepackage{amsmath}is in the preamble. - Undefined control sequence on
\absor\norm: these are not built-in names; define them with\providecommandor\DeclarePairedDelimiteras shown above. - Bars look too short around a fraction: a plain
\newcommand*\abs[1]{\lvert#1\rvert}has this vertical-spacing problem. Use the starred form or an explicit size from the\DeclarePairedDelimiterversion. - Spacing around bars in a larger expression looks off: avoid bare
|as a delimiter, as the amsmath guide advises, and use the left/right-aware commands.
Free alternatives: ways to set the bars
All packages named here are free and open on CTAN. The table compares the ways to produce absolute value covered above.
| Method | Requires | Sizing | What the source says |
|---|---|---|---|
|x| |
nothing | fixed | Not recommended as a delimiter; the bar is overloaded (amsmath guide). |
\lvert x \rvert |
amsmath | fixed, size with \bigl/\bigr |
Distinct opening and closing bar (amsmath guide). |
\left\lvert x \right\rvert |
amsmath | automatic | \left/\right is the manual’s alternative when the argument is taller (mathtools manual). |
\abs{x} via \providecommand |
amsmath | fixed | Recommended preamble definition; vertical spacing is poor for tall arguments (amsmath guide, mathtools manual). |
\abs*{x}, \abs[\Big]{x} via \DeclarePairedDelimiter |
mathtools | automatic or chosen | Starred form adds \left/\right; optional size command (mathtools manual). |
FAQ
What does |-6| mean in math?
It means the absolute value of -6, which is 6. Absolute value is the distance from zero, so it is never negative: |-6| = |6| = 6. In LaTeX, write it as \lvert -6 \rvert.
What is the symbol for the norm in LaTeX?
Use \lVert v \rVert from amsmath, which produces ‖v‖. The amsmath guide recommends defining \norm{v} as \lVert#1\rVert in the preamble.
Can you do absolute value in Sheets?
Yes. Google Sheets has an ABS(value) function that returns the absolute value of a number or cell reference. According to Google’s Docs Editors help, ABS(-26) gives 26 and ABS(A2) works on a cell. This is spreadsheet computation; it does not typeset the bars in LaTeX.
Can you provide some notes on absolute value?
Short notes: absolute value is distance from zero; |x| = x when x is zero or positive and -x when x is negative; the result is never negative. For typesetting, the notation is covered above. Related LaTeX notation guides include floor and ceiling symbols with mathtools macros, square roots in LaTeX, limits and integrals, and piecewise definitions with cases, which is how |x| is often defined.
Sources
- AMS/LaTeX Project, User’s Guide for the amsmath Package, version 2.1, 1999-12-13, section 4.14.2 “Vertical bar notations”: amsldoc.pdf; package page ctan.org/pkg/amsmath. Read 2026-11-07.
- Hoegholm, Madsen and the LaTeX3 project, The mathtools package, 2024/10/04, section 3.6 “Paired delimiters”: mathtools.pdf. Read 2026-11-07.
- Google Docs Editors Help, ABS function: support.google.com/docs/answer/3093459. Read 2026-11-07.







