Don’t want limit on top of varprojlim

math-operators

When in displaystyle mode, using \varprojlim_{i \in I}^{1} gives

enter image description here

However, I want to look more like

enter image description here

The above can be obtained by {\varprojlim_{i \in I}}^{1} but I was wondering if there's some way to create a command (say, \limit) such that \limit_{i \in I}^{1} would give the desired result.


MWE:

\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{equation*} 
    \varprojlim_{i \in I}^{1} \text{ vs. } {\varprojlim_{i \in I}}^{1}
\end{equation*}
\end{document}

Best Answer

You want that the subscript is centered on \varprojlim, without taking into account the exponent, so some measuring is necessary.

I suggest to use a different name, such as \invlim for the operator. I also provide a modified \varprojlim where the arrow is smaller.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
% use a smaller arrow
\def\varprojlim{\mathop{\mathpalette\varlim@{\leftarrowfill@\scriptstyle}}\nmlimits@}

\NewDocumentCommand{\invlim}{e{^_}}{%
  \IfNoValueTF{#1}{%
    \varprojlim\IfValueT{#2}{_{#2}}%
  }{%
    % measure the exponent
    \sbox\z@{$\m@th{}^{#1}\kern-\scriptspace$}
    \IfValueT{#2}
     {% measure the subscript
      \sbox\tw@{$\m@th\scriptstyle#2$}%
      % measure the operator
      \sbox4{$\m@th\varprojlim$}%
      \dimen@=\dimexpr(\wd\tw@-\wd4)/2\relax
      % typeset the operator
      \mathop{%
        \varprojlim\nolimits^{#1}
        % backup
        \kern-\wd\z@
      }\limits_{#2}%
      \ifdim\dimen@<\z@
        % the subscript doesn't overflow
        \kern\wd\z@
      \else
        \ifdim\dimen@>\wd\z@
          % no need to kern
        \else
          \kern\dimexpr\wd\z@-\dimen@\relax
        \fi
      \fi
     }%
  }%
}
\makeatother

\begin{document}

\begin{gather}
x\invlim_{i\in I} M_i     \\
x\invlim^1_{i\in I} M_i   \\
x\invlim^1_{i\in IJ} M_i  \\
x\invlim^1_{i\in IJK} M_i
\end{gather}

\end{document}

enter image description here

This only works in display style. If requested, we can make it to work also in text style, with the subscript on the side.

The “x” in front is just used to show the correct spacing.

Related Question