I’m trying to define an abs
command for absolute values using DeclarePairedDelimiter
from the mathtools
package, but I’m running into some spacing issues.
I’d normall write \sup_n \abs{a_n}
defined by \DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
.
But then there is some space missing.
I would instead expect the following output, which I get using \sup_n |a_n|
.
With \sup_n {\abs{a_n}}
this issue does not appear, but I find this additional pair of curly braces too cumbersome.
I also tried some variations, but both versions of \abs
seem to have the same issue.
\documentclass[a4paper,10pt]{scrartcl}
\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\DeclarePairedDelimiter{\altabs}{|}{|}
\begin{document}
\[
\sup_n |a_n| \quad % expected output
\sup_n \abs{a_n} \quad
\sup_n {\abs{a_n}} \quad % expected output
\sup_n \lvert a_n \rvert \quad
\sup_n \altabs{a_n} \quad
\sup_n {\altabs{a_n}} % expected output
\]
\end{document}
Where is this problem coming from, and how can I get DeclarePairedDelimiter
to give the right spacing?
\sup_n\lvert a_n\rvert
, you see it. Just like\sup(a_1,\dots,a_n)
should not have space.|...|
is not the correct syntax for absolute value.|
is a normal symbol (an ord), whereas\lvert
and\rvert
are|
with type math open and math close respectfully (just as()
). When\sub
sees an ord like a letter or|
it inserts a space, whereas it does not insert a space when it sees something of type math open. Internally\DeclarePairedDelimiter
will always make the fences into open and close types which is why your\abs
and\altabs
gives the same result.