[Tex/LaTex] absolute value in numerator of fraction

math-modepdftextexshop

I am having trouble writing a term of an equation which is fractional where only the numerator is inside the absolute value symbol. The syntax I used is:

\frac{\abs{\lambda_f}}{8\pi^2}

But I keep getting an error saying, "Undefined control sequence". I think the nested curly braces is the problem but not sure how to fix it.

Best Answer

Make sure the \abs macro is defined.

enter image description here

\documentclass{article}
\usepackage{mathtools}           % for '\DeclarePairedDelimiter' macro
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert} % define '\abs' macro
\begin{document}
$\frac{\abs{\lambda_f}}{8\pi^2}$\quad $\dfrac{\abs{\lambda_f}}{8\pi^2}$
\end{document}