5

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.

enter image description here

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?

enter image description here

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}
Werner
  • 603,163
Adam
  • 4,684

2 Answers2

4

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
    \addtolength{\dimen2}{-\dimen0}%
    \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. ;-)

enter image description here

egreg
  • 1,121,712
1

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}

enter image description here

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

enter image description here


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
  • 2
    @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 (http://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
  • @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
  • 1
    @Adam Just thought you should know that I updated the accepted answer to use \mathop rather than \mathrel after egreg correctly questioned my initial choice. – Steven B. Segletes Apr 17 '14 at 15:57