Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted
\usepackage{amsmath}

is missing.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.