1

I was trying to redefine the command \lim, but I was getting an error messege. The code was analogous to the following:

\documentclass[oneside,10pt]{amsart}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{mathrsfs}

\newcommand{\li}{\lim\limits} \renewcommand{\lim}{\li}

enter image description here

Any sort of help regarding the issue will be of great help.

Regards, Ralph

P.S: Is it happening because of the \lim\limits in the definition of \li? Just a wild guess.

  • 5
    You're making an infinite loop: the new \lim expands to \li\limits which expands to \lim\limits, which gives \li\limits\limits and so on. And you don't want to apply \limits indiscriminately, trust me. – egreg Jul 21 '21 at 16:30

1 Answers1

3

If you do, from a terminal, latexdef -c amsart lim, you obtain

\lim:
macro:->\qopname \relax m{lim}

You cannot go the way you do, because TeX expands macros and, with your definitions, you get successively

\lim
\li\limits
\lim\limits
\li\limits\limits
\lim\limits\limits
...

so you see that an infinite loop is created that soon fills TeX's memory (the input stack, as the error message says).

You might do

\documentclass[oneside,10pt]{amsart}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{mathrsfs}

\NewCommandCopy{\originallim}{\lim} \renewcommand{\lim}{\originallim\limits}

If you have an older TeX system (Overleaf is a candidate to not support \NewCommandCopy yet), you can replace the line

\NewCommandCopy{\originallim}{\lim}

with

\let\originallim\lim

because the initial latexdef tells us that this is safe.

However, you don't really want this. Let me show an example

\documentclass[oneside,10pt]{amsart}
\usepackage{lipsum}

\NewCommandCopy{\originallim}{\lim} \renewcommand{\lim}{\originallim\limits}

\begin{document}

\lipsum[1][1-2] $\lim_{x\to0}x^2=0$ \lipsum[2][1-3] $\lim_{x\to0}x^2=0$ \lipsum[3][1-3] $\lim_{x\to0}x^2=0$ \lipsum[4][1-3]

\end{document}

You get the output

enter image description here

that you should compare to what you'd get without the redefinition

enter image description here

I have no doubt on which one is better (the latter, of course). But the choice is yours.

egreg
  • 1,121,712