How can i write my own math operator with limits? I want it to look like:
\sum\limits_{e=1}^{m}
but with a capital A (if possible bigger than the normal text) instead of the sum.
Thanks for the help!
-
See also positioning - How does a math operator specify the horizontal position of its limits? - TeX - LaTeX Stack Exchange for some options if the math operators aren't horizontally symmetric i.e. you want to put the upper and lower limit not vertically aligned, such as for the ∫ operator.– user202729Dec 3, 2022 at 7:33
5 Answers
Use the \DeclareMathOperator*
command provided by the amsmath
package. Example:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\Aop}{A}
\begin{document}
\[ \Aop^a_b \]
\end{document}
-
4Where is the difference between
\DeclareMathOperator*
and\DeclareMathOperator
? Jan 9, 2016 at 21:53 -
12@moose
\DeclareMathOperator*
will use limits so subscript/superscript will go directly below and above the symbol, while\DeclareMathOperator
will not use limits and so subscript/superscript will go below right and above right.– BakuriuJan 30, 2016 at 9:25
We can scale the symbol to the height plus depth of the summation and then vertically center it with respect to the formula axis.
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\makeatletter
\DeclareRobustCommand\bigop[1]{%
\mathop{\vphantom{\sum}\mathpalette\bigop@{#1}}\slimits@
}
\newcommand{\bigop@}[2]{%
\vcenter{%
\sbox\z@{$#1\sum$}%
\hbox{\resizebox{\ifx#1\displaystyle.9\fi\dimexpr\ht\z@+\dp\z@}{!}{$\m@th#2$}}%
}%
}
\makeatother
\newcommand{\bigstar}{\DOTSB\bigop{\star}}
\newcommand{\bigA}{\DOTSB\bigop{\mathrm{A}}}
\begin{document}
\[
\sum_{i=1}^n\bigA_{i=1}^n x_i\dots\bigstar_{i=1}^n x_i
\qquad
\textstyle
\sum\bigA\bigstar_{i=1}^n x_i
\qquad
\scriptstyle
\sum\bigA\bigstar_{i=1}^n x_i
\qquad
\scriptscriptstyle
\sum\bigA\bigstar_{i=1}^n x_i
\]
\end{document}
A simpler but not not scalable version (it won't work in
\newcommand{\opA}{\mathop{\vphantom{\sum}\mathchoice
{\vcenter{\hbox{\huge A}}}
{\vcenter{\hbox{\Large A}}}{\mathrm{A}}{\mathrm{A}}}\displaylimits}
In this way the "A" will be as large as the \sum
symbol.
An enhanced version, where one can specify a correction factor for the big symbol in display style, as different symbols seem to require different factors.
\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\makeatletter
\DeclareRobustCommand\bigop[2][1]{%
\mathop{\vphantom{\sum}\mathpalette\bigop@{{#1}{#2}}}\slimits@
}
\newcommand{\bigop@}[2]{\bigop@@#1#2}
\newcommand{\bigop@@}[3]{%
\vcenter{%
\sbox\z@{$#1\sum$}%
\hbox{\resizebox{\ifx#1\displaystyle#2\fi\dimexpr\ht\z@+\dp\z@}{!}{$\m@th#3$}}%
}%
}
\makeatother
\newcommand{\bigstar}{\DOTSB\bigop{\star}}
\newcommand{\bigA}{\DOTSB\bigop[0.92]{\mathrm{A}}}
\newcommand{\bigDelta}{\DOTSB\bigop[1.05]{\Delta}}
\begin{document}
\[
\sum_{i=1}^n\bigA_{i=1}^n\bigDelta_{i=1}^n x_i\dots\bigstar_{i=1}^n x_i
\]
\begin{center}
$\textstyle
\sum \bigA \bigstar \bigDelta_{i=1}^n x_i
\qquad
\scriptstyle
\sum \bigA \bigstar \bigDelta_{i=1}^n x_i
\qquad
\scriptscriptstyle
\sum \bigA \bigstar \bigDelta_{i=1}^n x_i
$
\end{center}
\end{document}
\documentclass{article}
\usepackage{amsmath}
\def\Aop{\operatornamewithlimits{%
\mathchoice{\vcenter{\hbox{\huge A}}}
{\vcenter{\hbox{\Large A}}}
{\mathrm{A}}
{\mathrm{A}}}}
\begin{document}
\[ \Aop^a_b \sum_a^b \]
$ \Aop^a_b \sum_a^b $
\end{document}
Use \mathop
to turn A
into a "math operator", and then use \limits
to do sum-style limits:
$$\mathop{A}\limits_{e=1}^{m}$$
Do you really want A
, or do you want \bigwedge
?
egreg's answer is fine but works poorly for existing mathematical symbols. I recommend the following:
\newcommand{\operator}[1]{\mathop{\vphantom{\sum}\mathchoice
{\vcenter{\hbox{\huge $#1$}}}
{\vcenter{\hbox{\Large $#1$}}}{#1}{#1}}\displaylimits}
To define an operator 'A', you can now type
\newcommand{\opA}{\operator{\mathrm{A}}}
But you can also define an operator Theta:
\newcommand{\opTheta}{\operator{\Theta}}
Just remember that in the argument you pass to \operator
, you are in math mode.