Customizable limit & sum symbols
Not to steal anything from campa's very fine answer, but there is room for improvements to the proposed code.
If you want a generic way to prefix \lim
and \sum
and define commands in terms of the generic ones, an interface with xparse
is easier.
I agree with campa that the limits should be centered below the whole “prefixed limit”, but only with respect to the big operator in case of \sum
or similar cases.
\documentclass{article}
\usepackage{amsmath}
%\usepackage{xparse} % not needed with LaTeX 2020-10-01 or later
\NewDocumentCommand{\prelim}{mm}{%
\operatorname*{#1-{#2}}%
}
\NewDocumentCommand{\preop}{mO{\thinmuskip}m}{%
\DOTSB\operatorname{#1-}\mspace{-#2}#3%
}
\newcommand{\mulim}{\prelim{\mu}{\lim}}
\newcommand{\xlimsup}{\prelim{x}{\limsup}}
\newcommand{\musum}{\preop{\mu}[6mu]{\sum}}
\newcommand{\mubigcup}{\preop{\mu}{\bigcup}}
\begin{document}
\begin{gather*}
\mulim_{x\to0} f(x) \\
\xlimsup_{x\to\infty} f(x) \\
\musum_{i=1}^{n} a_i \\
\mubigcup_{i\in I}A_i
\end{gather*}
\end{document}
I'd avoid redefining \lim
and \sum
. For the occasional non predefined operator, you can use \prelim
and \preop
with the suitable arguments. The \preop
command has a middle optional argument that's used for improving the kerning between the prefix and the symbol, which is better with \sum
, but not with \bigcup
.
Here a possible realization, assuming that you are loading amsmath
.
\documentclass{article}
\usepackage{amsmath}
\makeatletter
\newcommand*{\plim}[1][]{%
\if\relax\detokenize{#1}\relax
\def\next{\qopname\relax m{lim}}%
\else
\def\next{\qopname\newmcodes@ m{#1-lim}}%
\fi
\next
}
\newcommand*{\psum}[1][]{%
\DOTSB
\if\relax\detokenize{#1}\relax\else
\operatorname{#1-}\mkern-\thinmuskip
\fi
\sum@\slimits@
}
\makeatother
\begin{document}
\begin{gather*}
\plim_{x\to0} \quad \plim[s]_{x\to0} \quad \plim[\mu]_{x\to0} \\[2ex]
\psum_i a_i \quad \psum[\mu]_i a_i
\end{gather*}
\end{document}
I have chosen the placing of the limits such that they are centered on the whole expression in case of the limit, but always only under the sum symbol (no matter what comes before).
Personally I think it's safer to use new macro names. Of course, nobody prevents you from changing the above code to
\renewcommand*{\lim}[1][]{%
\if\relax\detokenize{#1}\relax
\def\next{\qopname\relax m{lim}}%
\else
\def\next{\qopname\newmcodes@ m{#1-lim}}%
\fi
\next
}
\renewcommand*{\sum}[1][]{%
\DOTSB
\if\relax\detokenize{#1}\relax\else
\operatorname{#1-}\mkern-\thinmuskip
\fi
\sum@\slimits@
}
Be aware that there might be drawbacks.
You could also use the existing commands, and just redefine them to add an optional argument which adds a prefix.
\documentclass{article}
\usepackage{amsmath}
\let\oldlim\lim
\let\oldsum\sum
\renewcommand*{\lim}[1][]{%
\def\temp{#1}%
\ifx\temp\empty
\oldlim%
\else
#1\text{--}\!\oldlim%
\fi%
}
\renewcommand*{\sum}[1][]{%
\def\temp{#1}%
\ifx\temp\empty
\oldsum%
\else
#1\text{--}\!\!\oldsum%
\fi%
}
\begin{document}
\(\lim_{x\to 0} f(x)\)
\(\lim[\mu]_{x\to 0} f(x)\)
\[
\lim_{x\to 0} f(x)
\qquad
\lim[\mu]_{x\to 0} f(x)
\]
\(\sum_{n=0}^\infty f(n)\)
\(\sum[\mu]_{n=0}^\infty f(n)\)
\[
\sum_{n=0}^\infty f(n)
\qquad
\sum[\mu]_{n=0}^\infty f(n)
\]
\end{document}
I adjusted the spacing to something that I thought looked good here, but it can easily be changed in the redefinitions of \lim
and \sum
.