0

If I write

\[\left||x|-|y|\right|\]

I would expect it to look like the second of the following two expressions:

enter image description here

which I got by writing

\[\Big||x|-|y|\Big|\]

Shouldn't \left and \right adjust the size automatically? Or do I have to write \Big whenever I have two vertical bars, one after the other?

6

You should use \DeclarePairedDelimiter command from mathtools to define an \abs command. Doing so, you obtain a \abs* version which adds an implicit \left \right pair and detects the inner \abs. For fine-tuning you also have four variants with an optional argument: \abs[\big], \abs[\Big], &c.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\begin{document}

\begin{align*}
    \abs{\abs{x}-\abs{y}} & \le \abs{x-y} \\
    \abs*{\abs{x}-\abs{y}} & \le \abs{x-y}\\
    \abs[\Big]{\abs{x}-\abs{y}} & \le \abs{x-y}
\end{align*}

\end{document} 

enter image description here

@Mico made me observe the starred version works as you want because of the fourier font which uses special values of the parameters which control the delimiters sizes: \delimitershortfall and \delimiterfactor. It suffices to add \delimitershortfall=-1spto obtainthe same result with the default Computer Modern:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\begin{document}

\begin{align*}
    \abs{\abs{x}-\abs{y}} & \le \abs{x-y} \\
    \abs*{\abs{x}-\abs{y}} & \le \abs{x-y}\\
\end{align*}
\delimitershortfall=-1sp
\begin{align*}
    \abs{\abs{x}-\abs{y}} & \le \abs{x-y} \\
    \abs*{\abs{x}-\abs{y}} & \le \abs{x-y}\\
\end{align*}

\end{document} 

enter image description here

  • You may want to mention that if the OP doesn't wish to use the fourier font package, a similar effect (i.e., automatic growth of matched delimiters) may be achieved by executing \setlength{\delimitershortfall}{-1sp}. – Mico Aug 26 '17 at 12:19
  • 1
    @Mico: I didn't even know it was using the fourier fonts which made the starred version work. I used them only because I started with an already existing short file and changed a couple of lines. I'll update my answer in a moment, of course. – Bernard Aug 26 '17 at 12:45
2

\left and \right adjust size automatically, but in a purely typographic way, not semantic. Typographically, the inner | does not incur the need for bigger | than x already did.

So yes, you need to fine tune this if you want to emphasize the outer |. The same goes for parentheses.

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