Missing space with DeclarePairedDelimiter

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?

• The fact is that the space should not be there: if you use the proper \sup_n\lvert a_n\rvert, you see it. Just like \sup(a_1,\dots,a_n) should not have space. – egreg Nov 26 '18 at 11:33
• In addition to egregs comment, remember that |...| 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. – daleif Nov 26 '18 at 11:56
• I guess then that my latex code does not properly reflect what I actually want to express: I understand something like “sup(f)” as “sup( ) applied to f”, but “sup |f|” as “sup (written without paratheses) applied |f|”, not as “sup| | applied to f”. Hence I expect the same spacing for both “sup f” and “sup |f|”. – Jendrik Stelzner Nov 26 '18 at 12:19

There should be no space between the operator name and a delimiter, so the output one gets from

\sup_{n}\lvert a_{n}\rvert


is right (and is one of the reasons why amsmath introduced \lvert and \rvert to begin with).

On the other hand, you may like the thin space when the delimiter is a vertical bar. Easy enough: add a dummy \mathop{} before it.

\documentclass[a4paper,10pt]{scrartcl}
\usepackage{mathtools}

\DeclarePairedDelimiter{\absinner}{\lvert}{\rvert}
\DeclarePairedDelimiter{\altabsinner}{|}{|}

\newcommand{\abs}{\mathop{}\absinner}
\newcommand{\altabs}{\mathop{}\altabsinner}

\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 \altabs{a_n} \quad \sup_n {\altabs{a_n}} % expected output$

\begin{alignat*}{3}

• Is there a reason why you chose an \mathop{} instead of just {}? – Jendrik Stelzner Dec 1 '18 at 11:31
• I ended up going with this solution but used \DeclarePairedDelimiterXPP to place the dummy \mathop{}. – Jendrik Stelzner Apr 16 at 22:45