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}

enter image description here

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 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 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 at 19:56
up vote 3 down vote accepted

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 :. enter image description here

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

  • 1
    Define my own \newmcodes@?! Are you kidding me? :) – Denis Bitouzé Sep 19 at 20:20
  • 1
    @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" – jfbu Sep 19 at 21:03
  • 1
    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 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. – jfbu Sep 20 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}

enter image description here

  • 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 at 19:59
  • 1
    @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 at 20:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.