7

In my preamble I have the following

\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\makeatletter
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother

without really knowing how it works. But it does work great in most cases. But the following looks really bad

\norm{a} - \norm{b_{t|t}}

because the sizes of the delimiters are different. I therefore want to control their size manually, as in \big, \Big, etc...

Anybody know a smart way?

LaRiFaRi
  • 43,807
Patrick
  • 309
  • \norm[\big]{…}, for instance. – Bernard Aug 12 '14 at 21:24
  • @DavidCarlisle From what I can tell by commenting it out, that seems to be what takes care of the automatic resizing. – Patrick Aug 12 '14 at 21:29
  • @Bernard Tried, didn't work – Patrick Aug 12 '14 at 21:29
  • @Patrick no, you define \norm then you save that definition as \oldnorm then you define \norm to be oldnorm so get back to where you were. – David Carlisle Aug 12 '14 at 21:31
  • Apart from David Carlisle's comment: \norm* is supposed to be \oldnorm and \norm should expand to \oldnorm*... what is the starred version of the command at all? Is it automatically defined by \DeclaredPairedDelimiter? I am asking, because I have never used that command before –  Aug 12 '14 at 21:35
  • 1
    @Patrick: Sorry, I didn't notice you interverted \norm and \norm*: it's \norm*[\big]{…} you have to write. – Bernard Aug 12 '14 at 21:38
  • @DavidCarlisle I've noticed, and I thought it was for enabling the "star" functionality. But really, when I only have the \DeclarePairedDelimiter line in my preamble, then the automatic resizing functionality disappears. – Patrick Aug 12 '14 at 21:39
  • @ChristianHupfer See here for source: http://tex.stackexchange.com/questions/43008/absolute-value-symbols – Patrick Aug 12 '14 at 21:42
  • @Patrick: Thanks for the link, you should have provided the link in your original post perhaps ;-) –  Aug 12 '14 at 21:49
  • @Patrick: Personnaly, I think it's better to enable \big by default, but that requires twisting again the definition. – Bernard Aug 12 '14 at 21:51

1 Answers1

5

This is a good example why I usually discourage using \left and \right indiscriminately.

With \DeclarePairedDelimiter\norm{\lVert}{\rVert} you are defining the macro \norm that can be used in the following ways:

\norm{x}
\norm[\big]{x}
\norm[\Big]{x}
\norm[\bigg]{x}
\norm[\Bigg]{x}
\norm*{x}

The simple call does nothing to the size of the delimiters, the following ones with the optional argument specify the size “manually”, the last one tells TeX to use “automatic” sizing.

The trick you're using tells TeX that if you call \norm{x}, \oldnorm*{x} is executed and, when \norm*{x} is found, \oldnorm{x} is actually executed.

Here's how you could do it:

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter\norm{\lVert}{\rVert}%
\makeatletter
\let\oldnorm\norm
\def\norm{\@ifstar{\oldnorm}{\oldnorm*}}
\makeatother

\begin{document}

(1) $\norm{a} - \norm{b_{t|t}}$

\bigskip

(2) $\norm*[\big]{a} - \norm*[\big]{b_{t|t}}$

\bigskip

(3) $\norm*{a} - \norm*{b_{t|t}}$

\end{document}

enter image description here

I have no doubt whatsoever that (3) is the only correct way. The trick you're using with \oldnorm is simply useless: just remove it and type

\documentclass{article}
\usepackage{mathtools}

\DeclarePairedDelimiter\norm{\lVert}{\rVert}%

\begin{document}

(3) $\norm{a} - \norm{b_{t|t}}$

\end{document}

using the optional argument or the *-form only when they are really necessary.

This input will give the form (3) above.

egreg
  • 1,121,712
  • My personal taste would make me choose version 2: version 3 seems too small when you have letters with ascenders or descenders — not to speak of subscripts, and I think that within one expression, all \Verts should have, as much as is reasonable, the same height. – Bernard Aug 12 '14 at 21:57
  • They have the same height; the version with \big around a would also need some horizontal space. – egreg Aug 12 '14 at 22:06
  • I agree they have the same height. Maybe adding .5mu on both sides with \big would be necessary indeed. But my opinion is that it should be \big by default: this is the most common case. – Bernard Aug 12 '14 at 22:09