\DeclareMathOperator adds spaces after the periods contained in its second argument (name text)

The following MCE points out that \DeclareMathOperator, if its second argument (name text) contains periods, adds spaces after those periods:

\documentclass{article}
\usepackage{amsmath}
%
\DeclareMathOperator{\limone}{l.i.m.}
\newcommand\limtwo{\mathop{\mathrm{l.i.m.}}}
%
\begin{document}
\begin{align*}
A_t & =\limone A_{n,t} \\
A_t & =\limtwo A_{n,t} \\
A_t & =\text{l.i.m.} A_{n,t}
\end{align*}
\end{document}


Do you know why and how to get rid of these spaces?

• \DeclareMathOperator{\limone}{l{.}i{.}m{.}} Note that while the l.i.m. will still line up with your \text case, there will be a gap following the last ., because l.i.m. is now an operator, whereas \text{l.i.m.} is a math atom. – Steven B. Segletes Sep 19 '18 at 19:48
• Using {.} ? Untested, it just makes the dot an ord. Which math operator is that? Never seen one with punctuation in it before – daleif Sep 19 '18 at 19:50
• @daleif {.} works nicely indeed. Concerning the operator, some authors use it for denoting the convergence in the mean square sense. I agree it is quite strange :) – Denis Bitouzé Sep 19 '18 at 19:56

2 Answers

Compare with

$l\mathpunct{.}i\mathpunct{.}m$


Indeed, your \limone gives \qopname \newmcodes@ o{l.i.m.} and \newmcodes assigns \mathpunct category to the dot (which will be taken in letters font, not operators...). Another strangeness of \newmcodes@.

\newmcodes@ ->\mathcode \'39\mathcode \*42\mathcode \."613A\ifnum \mathcode
\-=45 \else \mathchardef \std@minus \mathcode \-\relax \fi \mathcode \-45\ma
thcode \/47\mathcode \:"603A\relax


You will have same \mathpunct spacing with :.

What to do? You can always define your own \newmcodes@ to replace above definition.

• Define my own \newmcodes@?! Are you kidding me? :) – Denis Bitouzé Sep 19 '18 at 20:20
• @DenisBitouzé I knew that would keep you busy while I went to watch cartoons on replay-tv ;-). Try \let\newmcodes@\relax or ok if you want it more politically correct, copy above (beware linebreaks) removing the 6 in "613A" – user4686 Sep 19 '18 at 21:03
• I guess that when the code for \qopname was being developed by Spivak and the AMS (it went essentially unchanged into amsmath.sty from amstex.tex) the use cases dictated that the period had to be considered as punctuation in an operator name. – egreg Sep 19 '18 at 21:37
• @egreg you are right, surely. I wonder what kind of use cases, and why one would treat an operator name like a piece of text. – user4686 Sep 20 '18 at 8:38

\DeclareMathOperator{\limone}{l{.}i{.}m{.}} will fix the excess space in row 1, making it like row 2. Note that while the l.i.m. will still line up with your \text case, there will be a gap following the last ., because l.i.m. (in the form of \limone or \limtwo) is now an operator, whereas \text{l.i.m.} is a math atom.

\documentclass{article}
\usepackage{amsmath}
%
\DeclareMathOperator{\limone}{l{.}i{.}m{.}}
\newcommand\limtwo{\mathop{\mathrm{l.i.m.}}}
%
\begin{document}
\begin{align*}
A_t & =\limone A_{n,t} \\
A_t & =\limtwo A_{n,t} \\
A_t & =\text{l.i.m.} A_{n,t}
\end{align*}
\end{document}


• It does the trick, indeed. But why this behaviour without the braces? And agree with your note (I added the \text example in order to show the spaces with \DeclareMathOperator didn't come from a possible underlying "text" mode). – Denis Bitouzé Sep 19 '18 at 19:59
• @DenisBitouzé Not sure, but it may be related to this: \gdef\newmcodes@{\mathcode\'39\mathcode\*42\mathcode\."613A% \mathcode\-45\mathcode\/47\mathcode\:"603A\relax}, declared in amstex.sty`. – Steven B. Segletes Sep 19 '18 at 20:09