Different ways to get Absolute Value (|x|) symbol in LaTeX
In this tutorial, I will show you how to get the Absolute value symbol in different ways in LaTeX.
The Absolute value symbol is represented by a value between two pipes (|) symbols like |a|. To get this symbol in LaTeX you can use the “|” symbol from the keyboard.
\documentclass{article} \begin{document} Absolute value symbol in \LaTeX: $|x|$ and $|\frac{1}{x^2}|$ \end{document}
Output:
Auto-adjustable pipe symbol in LaTeX
In the above example, you can see when the value is in fraction the pipe symbol is not spanned properly. In order to get an adjustable pipe (|) symbol you have to use \left|<value>\right|
command.
\documentclass{article} \begin{document} \noindent Absolute value symbol in \LaTeX: $|x|$ and $\left|\frac{1}{x^2}\right|$\\[4pt] \verb!|\frac{1}{x^2}|! : $|\frac{1}{x^2}|$\\[4pt] \verb!\left|\frac{1}{x^2}\right|! : $\left|\frac{1}{x^2}\right|$ \end{document}
Output:
Auto-adjustable pipe symbol with physics package
You Can also use the \abs{<value>}
command provided by the physics
package. This command also gives you auto adjustable pipe symbol based on the fraction height.
\documentclass{article} \usepackage{physics} \begin{document} \noindent\textbf{Responsive pipe symbol using physics package:} \\[5pt] $\abs{x}$\\[4pt] $\abs{\frac{1}{x^2}}$\\[4pt] $\abs{\frac{1}{\frac{1}{m}}x^2}$ \end{document}
Output:
Other commands to get absolute value symbol
All the outputs are taken in display math mode.
Command | Output |
---|---|
\left| \frac{1}{x^2} \right| | ![]() |
\big| \frac{1}{x^2} \big| | ![]() |
\bigg| \frac{1}{x^2} \bigg| | ![]() |
\Bigg| \frac{1}{x^2} \Bigg| | ![]() |
\left\lvert \frac{1}{x^2} \right\rvert from amsmath | ![]() |
\abs{\frac{1}{x^2}} from physics | ![]() |
\mid \frac{1}{x^2} \mid | ![]() |
Leave a Reply