# Question about limits in lim command and scale in mathtools package

This is a follow up question regarding the limits in \lim command and mathtools package. To begin with how can I make the limits to start at the beggining of the lim symbol and not ahead of it? Meaning the lim symbol and the limits not to be centered.

Also in the mathtool package if I use the scale option then the limits are scaled but as it seems to me around a point and so as the scale becomes smaller the larger the vertical gap between the limits and the lim symbol becomes. How can I fix that so that the vertical space will remail the same as the original in the lim command? And why is that happening?

This is a the code I used to try some cases, which belongs to Peter Grill who posted it to answer a previous question of mine.

\documentclass[12pt]{article}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{calc}

% http://tex.stackexchange.com/questions/60453/reducing-font-size-in-equation/
\newcommand*{\Scale}[2][4]{\scalebox{#1}{$#2$}}%
\newcommand*{\Resize}[2]{\resizebox{#1}{!}{$#2$}}%

\begin{document}
\noindent
Without \verb|\mathclap|:
$\lim_{n\to +\infty}x(n)$
But with \verb|\mathclap|::
$\lim_{\mathclap{n \to +\infty}}x(n)$
Using \verb|\scriptstyle| to resize:
$\lim_{\scriptscriptstyle n \to +\infty} x(n)$
Using \verb|\Scale|
$\lim_{\Scale[0.5]{n \to +\infty}} x(n)$
Using \verb|\Resize|
$\lim_{\Resize{\widthof{\lim{}}}{n \to +\infty}} x(n)$
\end{document}

-

Stacks make this very easy. The alignment is set with a mode parameter (\stackalignment), the gap is set with an optional stacking argument. The use of \useanchorwidth says to not allow the width of the underset to affect the spacing to the next item. EDITED to use \mathop.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{graphicx}
\stackMath
\def\stackalignment{l}\def\useanchorwidth{T}
\begin{document}
$\mathop{\stackunder[3pt]{\lim}{\scriptstyle n\rightarrow+\infty}} x(n)$
$\mathop{\stackunder[2.5pt]{\lim}{\scriptscriptstyle n\rightarrow+\infty}} x(n)$
$\mathop{\stackunder[2pt]{\lim}{\scalebox{.33}{n\rightarrow+\infty}}} x(n)$
\end{document}


If \usearchorwidth had been defined as {F} instead of {T}, the result would look like

The alignment and anchorwidth parameters can be directly incorporated into the syntax, which has the further advantage of making their invocation impervious to the current mode settings.

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{graphicx}
\stackMath
\begin{document}
$\mathop{\stackengine{3pt}{\lim}{\scriptstyle n\rightarrow+\infty}{U}{l}{F}{T}{S}} x(n)$
$\mathop{\stackengine{2.5pt}{\lim}{\scriptscriptstyle n\rightarrow+\infty}{U}{l}{F}{T}{S}} x(n)$
$\mathop{\stackengine{2pt}{\lim}{\scalebox{.33}{n\rightarrow+\infty}}{U}{l}{F}{T}{S}} x(n)$
\end{document}

-
You mean that I can change the vertical gap? – Adam Apr 15 '14 at 19:51
@Adam The optional argument to \stackunder and/or the first argument to \stackengine (the alternative form at the end of my answer) are the gaps between the stacked items. See the stackengine package documentation (ctan.org/pkg/stackengine) for a discussion of what "gap" means for so-called short vs. long stacks. – Steven B. Segletes Apr 15 '14 at 19:54
Great thank you! – Adam Apr 16 '14 at 16:42
@StevenB.Segletes \mathrel??? – egreg Apr 16 '14 at 17:41
@egreg \mathop seemed too small, but I guess I shouldn't break the rules. – Steven B. Segletes Apr 16 '14 at 17:43

This doesn't work in subscripts or superscripts (it might be made so):

\documentclass{article}

\makeatletter
\newcommand{\awfullim}{\@ifnextchar_{\@awfullim}{\lim}}
\newcommand{\@awfullim}[2]{% #1 is _
\settowidth{\dimen0}{$\lim$}%
\settowidth{\dimen2}{$\scriptstyle#2$}%
\ifdim\dimen2<\dimen0
\lim_{#2}%
\else
\kern-\dimen2 \lim_{\kern\dimen2 #2}%
\fi
}
\makeatother

\begin{document}
$\awfullim_{x\to0^+}f(x)=\awfullim_{y\to+\infty}f(1/y)$
\end{document}


The name I used tells you how much I like this idea. ;-)

-
Can I use it with mathclap so there is no space between the \lim command and the function? Also what do you mean about the subscripts and superscripts? – Adam Apr 15 '14 at 19:49
@Adam This is already horrible; removing the space above the limits is abhominable. ;-) – egreg Apr 15 '14 at 20:02
I agree but can be done? – Adam Apr 15 '14 at 20:04
@Adam Just use \lim_{\mathmakebox[\dimen0][l]{\kern\dimen2 #2}} – egreg Apr 15 '14 at 20:25
Ok thank you very much! – Adam Apr 15 '14 at 23:44