5

How do I introduce a paired delimiter with \DeclarePairedDelimiter from mathtools, if the name that I want to use for the delimiter is already declared by some other package?

For example:

\documentclass{minimal}

\usepackage{mathtools}
\usepackage{physics}

\DeclarePairedDelimiter{\norm}{\lvert\lvert}{\rvert\rvert}

\begin{document}
I do not even need to use $\norm{v}$ to have an error.
\end{document}

Note that, unlike this question or this other question I am wondering about overriding an existing macro to make it a paired delimiter within the package mathttools, and not how to make a \newcommand with a name that has been already defined (in the latter case, I can, for example, \renewcommand).

Note that the question is not about how should you typeset a norm operator.

The reason why one may want to redefine a command in physics package as a mathtoolspaired delimiter is that a paired delimiter can open and close on two different lines.

Antonio
  • 173

1 Answers1

5

As noted in my comment, one can undeclare a macro, such as \norm, with \let\norm\relax. And then, one can declare it as if it did not yet exist. The admonition is to be careful in redeclaring standard LaTeX (or package-defined) symbols, lest you break something else.

\documentclass{minimal}

\usepackage{mathtools}
\usepackage{physics}
\let\norm\relax
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}
I do not even need to use $\norm{v}$ to have an error.
\end{document}

enter image description here

As campa notes, the use of \lVert and \rVert IS STRONGLY preferable to the use of \lvert\lvert and \rvert\rvert, as in

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

I have thus adopted that change in my answer.

Finally, Andrew notes that had \norm been defined via \DeclarePairedDelimiter, this simple method with \let would not work, since there is an associated macro also defined.

  • 1
    \norm is not standard LaTeX but defined in the physics package. – Andrew Swann Apr 28 '16 at 15:17
  • @AndrewSwann Thanks. I made a clarification. – Steven B. Segletes Apr 28 '16 at 15:25
  • @campa It would seem that \lVert ... \rVert is equivalent to what the physics package provides. Thus, there would be no need to redefine it. But I will edit to make a note of it. – Steven B. Segletes Apr 28 '16 at 15:30
  • 1
    I find the space between the two single bars way too large... \lVert is not just built out of two |, it's a separate glyph – campa Apr 28 '16 at 15:33
  • 2
    Also note that had \norm been defined via \DeclarePairedDelimiter, this simple method with \let would not work, since there is an associated macro also defined. – Andrew Swann Apr 28 '16 at 15:33
  • 1
    I want \norm to be able to span multiple lines, which I do not seem to get from the physics package, but I do get by defining it as a mathtools paired delimiter. – Antonio Apr 28 '16 at 15:38
  • 2
    Another strong argument against the version with \lvert\lvert...\rvert\rvert: try \norm*{\frac{1}{2}} in display math, or $\norm[\Big]{a}$, and enjoy the result :-) – campa Apr 28 '16 at 15:46
  • @campa Revised to heed your advice. – Steven B. Segletes Apr 28 '16 at 15:50