# How to create my own math operator with limits?

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!

-

## migrated from stackoverflow.comJul 18 '11 at 20:57

This question came from our site for professional and enthusiast programmers.

Thanks for all the answers! really quick, really precise!! –  user6776 Jul 19 '11 at 8:35
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  adn May 11 at 19:55

\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.

For a geometric symbol, it's perhaps better just to scale it, instead of guessing the size.

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\makeatletter
\DeclareRobustCommand{\bigstar}{%
\mathop{\vphantom{\sum}\mathpalette\bigstar@\relax}\slimits@
}

\newcommand{\bigstar@}[2]{%
\vcenter{%
\sbox\z@{$#1\sum$}%
\hbox{\resizebox{.9\dimexpr\ht\z@+\dp\z@}{!}{$\m@th\star$}}%
}%
}
\makeatother

\begin{document}
$\sum_{i=1}^n\bigstar_{i=1}^n x_i \qquad \textstyle \sum\bigstar_{i=1}^n x_i \qquad \scriptstyle \sum\bigstar_{i=1}^n x_i \qquad \scriptscriptstyle \sum\bigstar_{i=1}^n x_i$
\end{document}


-
I'd like to do the same but using \star. What are the 4 sizes used in the choice? I'd like to use \LARGE\star. Is there different sizes for display or inline math? –  Sigur May 11 at 13:48
@Sigur I added the code for the big star; I used just 90 percent of the size of a summation symbol, because the star has large overshoot. –  egreg May 11 at 15:21
thanks so much. Amazing and beautiful. Since I like to use \textstyle size in displayed mode (the \sum in displaystyle is too big in my opinion) should I use \vphantom{\textstyle\sum}? –  Sigur May 11 at 15:32
@Sigur Just use \mathop{\textstyle\bigstar} –  egreg May 11 at 15:37
sorry. Use it where? In the text body? If I well understood, you made a box with the same height as the one produced by \sum. But every time I use \sum in display mode I use \textstyle and \limits o make the summation smaller. I'd like to define the star symbol in such a way that I don't need to use \textstyle inside display mode. Simply $\bigstar_{i=1}^n$ with the same size as $\textstyle \bigstar\limits_{i=1}^n$. –  Sigur May 11 at 15:43

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

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\Aop}{A}
\begin{document}
$\Aop^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?

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


-

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.

-