When evaluating an integral, often the integral symbol \(\int\) appears with the same limits repeatedly. A "memory" command \memint allows for the limits to be typed once when the integral first appears and omitted thereafter. In particular, there are two versions of \memint: a starred version \memint*[<lower limit>][<upper limit>] records the lower limit <lower limit> and the upper limit <lower limit> into memory. From then on, the unstarred version \memint will insert a integral with the recorded limits. In addition to saving time typing, \memint simplifies the LaTeX code, so it is easier to edit and find mistakes.

WARNING: Be careful while using this command because each time the starred version is called, it changes the definition for all of the unstarred versions until the next starred version. Thus, if you add \memlim* into the middle of text where you are already using \memlim with a different definition, you can unintentionally change the rendered equations. For this reason, I restrict the usage of each remembered command to a single equation.

Definition
% The 'xparse' package provides \NewDocumentCommand
\usepackage{xparse}
\NewDocumentCommand{\memint}{sO{}O{}}{%
    \IfBooleanT{#1}%
    {% If a star
        % "\gdef" is used to define a global macro.
        \gdef\memintlimits{_{#2}^{#3}}%
    }
    \int\memintlimits
}

Examples

Code Output
\memint*[1][\infty] \frac{1}{x} 
= \memint \frac{1}{x}
$$\begin{aligned} \int_{1}^{\infty} \frac{1}{x} &= \int_{1}^{\infty} \frac{1}{x} \end{aligned} $$

Updated: