# How can I embed \lvert and \rvert into the numerator ?

How can I embed \lvert and \rvert into the numerator?

$1 - \frac{ \lvert 1 - t_2 \rvert}{y}$


The above line gives Undefined control sequence error.

-

\usepackage{amsmath}


is missing.

-

Herbert's answer is sufficient, but I would like to suggest \usepackage{mathtools} as well (it automatically loads amsmath), and then

\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}


The fraction can then be written as \frac{ \abs{1-t_2} }{y}.

Using \abs gives a number of advantages:

• The code is easier to read (at least, I think so), because one recognizes "absolute value".

• Scaling only needs to be done in one place, namely the optional argument of \abs:

Compare

\abs[\Big]{ \int_a^b f(x) }


with

\Bigl \lvert \int_a^b f(x) \Bigr\rvert

• (there is also an \abs* version, which is equivalent to prepending \left and \right to \lvert and \rvert, but I think this has a tendency to produce too large delimiters; I prefer to find an appropriate size by hand)

• It is impossible to forget the closing delimiter, since it will produce a missing right brace error.

The mathtools package also provides lots of other nice features.

-