6

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.

3
  • 1
    \let\norm\relax prior to the declaration. But be wary of redeclaring standard symbols. Apr 28, 2016 at 15:08
  • This solved the problem for me.
    – Antonio
    Apr 28, 2016 at 15:10
  • 6
    Possible duplicate: Undefining custom commands
    – Werner
    Apr 28, 2016 at 15:31

1 Answer 1

6

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.

8
  • 1
    \norm is not standard LaTeX but defined in the physics package. Apr 28, 2016 at 15:17
  • 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, 2016 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. Apr 28, 2016 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, 2016 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, 2016 at 15:46

Not the answer you're looking for? Browse other questions tagged .