60

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!

1

5 Answers 5

45

Use the \DeclareMathOperator* command provided by the amsmath package. Example:

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\Aop}{A}
\begin{document}
\[ \Aop^a_b \]
\end{document}
2
  • 4
    Where 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.
    – Bakuriu
    Jan 30, 2016 at 9:25
45

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}

enter image description here

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.

enter image description here

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}

enter image description here

0
10
\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}

enter image description here

9

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?

6

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.

You must log in to answer this question.