Use `\big\vert f(x) \big\vert` or `\big\lvert f(x) \big\rvert` or `\bigl\lvert f(x) \bigr\rvert`

You asked,

which of the following gives the proper spacing about "$f(x)$"?

$\big\vert f(x) \big\vert$
$\big\lvert f(x) \big\rvert$
$\bigl\lvert f(x) \bigr\rvert$

First off, you actually left off the following, relevant option:

$\bigl\vert f(x) \bigr\vert$

Second, it so happens that if the "math atom" (to use some TeX jargon) that is placed between the vertical bars is f(x), then all four options produce the exact same output.

Third, does the preceding finding mean that writing

$\big\vert <some math atom> \big\vert$

is always typographically ok -- and maybe even best because it's the simplest of the four options? Not at all! To verify this, consider the following MWE (minimum working example):

\documentclass{article}
\usepackage{amsmath} % for '\lvert' and '\rvert' directives
\begin{document}
\obeylines
$\big\vert   -1 \big\vert$ 
$\big\lvert  -1 \big\rvert$
$\bigl\vert  -1 \bigr\vert$
$\bigl\lvert -1 \bigr\rvert$
\end{document}

and its output:

enter image description here

Only the latter two are typographically correct, as they treat the - ("minus") symbols as a unary rather than as a binary operator.

In short, \bigl\vert <some math atom> \bigr\vert is definitely better than \big\vert <some math atom> \big\vert, typographically speaking, as it produces the correct spacing in all cases.

A final remark, prompted by a comment from barbara beeton: For the code examples used here, it's not necessary to increase the size of the vertical bars. However, I'm assuming your real use case involves expressions such as $\bigl\vert -\int_0^1 f(x)\,dx \bigr\vert$.


Differences when \big is used

There's no difference at all between \big|, \big\vert and \big\lvert. The reason is that \big (and also its siblings \Big, \bigg and \Bigg) make an ordinary symbol out of the following delimiter, after forcing it to be a larger size.

Thus whether you use |, \vert or \lvert after \big is immaterial. In the first case TeX looks at the \delcode of |, which is "26A30C. In the second case it looks at the definition of \vert, which is \delimiter"026A30C; the definition of \lvert is \delimiter 69640972 (hexadecimal "426A30C). If we supplement this with the information that the \mathcode of | is "026A we have the whole picture.

How does \big work?

When we say \big<symbol>, the <symbol> can be either a character or a control sequence; if it is a character, it must have a positive \delcode; if it is a control sequence it must be a macro whose meaning starts with \delimiter followed by a 27 bit number. These are the same requirements for something following \left and not by chance: indeed \big<symbol> is realized by doing something like

{\left<symbol><empty box>\right.}

where the <empty box> has suitable vertical size to trigger \left choosing a larger variant. (I'm hiding some detail, as usual.) The braces around the construction make the object an ordinary symbol.

What's the difference between \vert and |?

None, as far as the behavior in math formulas is concerned. They behave as ordinary symbols.

What's the difference between \lvert and \vert?

This is a big one! \lvert is considered as an opening atom; its companion \rvert is a closing atom. The commands have been introduced by amsmath (not by the LaTeX kernel), in order to avoid bad spacing: just considering the output of

|-1|+\vert\sin x\vert

versus

\lvert-1\rvert+\lvert\sin x\rvert

clears up the matter. In the first formula, using | instead of \vert or conversely produces the same output.

How does \bigl work?

With \bigl<symbol>, TeX will do

\mathopen{\left<symbol><empty box>\right.}

that is, the same as before, but with \mathopen acting on the object, which makes it to be spaced correctly. Again it's immaterial whether we use

\bigl|  \bigl\vert  \bigl\lvert

The action of \bigr is similar: with \bigr<symbol> we obtain

\mathclose{\left<symbol><empty box>\right.}

which is appropriate for a closing atom.

There's also \bigm

If we do \bigm<symbol> we obtain

\mathrel{\left<symbol><empty box>\right.}

which is appropriate for the <symbol> used as a relation symbol. For instance, it would be correct to use

\bigl\{ x\in X \bigm| <condition> \bigr\}

in case we need larger fences. Again, \bigm|, \bigm\vert, \bigm\lvert or even \bigm\rvert are exactly the same.

Should I use \lvert and \rvert after \bigl and \bigr?

Yes, we should. But laziness has its merits, so the simpler \bigl| is handier.

Is \big| banned from use?

Not at all! If we want a larger vertical bar to denote restriction of a function or evaluation at a point, we can certainly use \big|, say for

f\big|_{A}
f(x)\big|_{x=0}

(in the second case, perhaps \Big| would be better, but it's a matter of taste).

Graphical examples

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}

\begin{document}

\renewcommand{\arraystretch}{1.2}

\begin{tabular}{@{}ll@{}}
Input & Output \\
\midrule
\verb!|-1|+\vert\sin x\vert! &
  $|-1|+\vert\sin x\vert$ \\
\verb!\lvert-1\rvert+\lvert\sin x\rvert! &
  $\lvert-1\rvert+\lvert\sin x\rvert$ \\
\midrule
\verb!\big|-1\big|+\big\vert\sin x\big\vert! &
  $\big|-1\big|+\big\vert\sin x\big\vert$ \\
\verb!\bigl\lvert-1\bigr\rvert+\bigl\lvert\sin x\bigr\rvert! &
  $\bigl\lvert-1\bigr\rvert+\bigl\lvert\sin x\bigr\rvert$ \\
\verb!\bigl|-1\bigr|+\bigl|\sin x\bigr|! &
  $\bigl|-1\bigr|+\bigl|\sin x\bigr|$ \\
\end{tabular}

\end{document}

enter image description here

Tags:

Math Mode