# Aligning own operator with limits in MathJax (bug or not?)

I want to create an own operator with limits which would be analogous to $$\sum_{i=1}^k\, \text{or}\, \prod_{i=1}^k$$ in the sense that the limits should be in the exact same position, but there should be another letter. But when I tried using "\mathop" I ran into problems: $$\mathop{\LARGE \mathrm A}_{i=1}^k \sum_{i=1}^k$$ As you can see, the "A" is badly aligned and it doesn't match the "\sum" command. Is this a bug? Or is there another technique which solves this problem?

"\DeclareMathOperator*" doesn't work either: $$\DeclareMathOperator*{\A}{\LARGE A}\A_{i=1}^k \sum_{i=1}^k$$

It is not a bug. Your large "A" operator sits on the baseline just as a large "A" would; that is its natural position. The summation sign is centered on the math axis, and that is its natural position.

In order to center the "A" on the math axis, you need to use \vcenter. In actual $$\rm\TeX$$ (or $$\rm\LaTeX$$), this takes a bit more work, but in MathJax, you can just put the \vcenter around what you want to center. E.g.

\mathop{\vcenter{\LARGE \mathrm A}}


$$\sum_{i=1}^k\mathop{\vcenter{\LARGE \mathrm A}}_{i=1}^k x_i$$

You can use

\operatorname{\vcenter{\LARGE\mathrm A}}}


as well, or if you want to make a macro for it,

\DeclareMathOperator{\A}{\vcenter{\LARGE\mathrm A}}


so that \A will now produce your operator.

$$\DeclareMathOperator{\A}{\vcenter{\LARGE\mathrm A}}\DeclareMathOperator*{\varA}{\vcenter{\mathchoice{\LARGE\text{A}}{\Large\text{A}}{\Large\text{A}}{\large\text{A}}}}\DeclareMathOperator*{\varvarA}{\vphantom{\sum}\vcenter{\mathchoice{\LARGE\text{A}}{\Large\text{A}}{\Large\text{A}}{\large\text{A}}}}$$Basically @DavideCervone's answer has solved the aligning issue, but I would like to add a few more words on some other aspects of defining a new operator.

The definition \DeclareMathOperator{\A}{\vcenter{\LARGE\mathrm A}} works fine in display style, but not so in text style: \sum\limits_{k = 1}^n and \A\limits_{k = 1}^n render as $$\sum\limits_{k = 1}^n$$ and $$\A\limits_{k = 1}^n$$, respectively (Note that the sizes mismatch and \limits fails).

To make \limits work, \DeclareMathOperator* should be used in place of \DeclareMathOperator. And to make the size match, \mathchoice should be used in the definition:

\DeclareMathOperator*{\varA}{\vcenter{\mathchoice{%
\LARGE\text{A}}{%
\Large\text{A}}{%
\Large\text{A}}{%
\large\text{A}}}}


Test: Display: $$\displaystyle \sum\limits_{k = 1}^n \quad \varA\limits_{k = 1}^n$$, text: $$\sum\limits_{k = 1}^n \quad \varA\limits_{k = 1}^n$$, script: $$\scriptstyle \sum\limits_{k = 1}^n \quad \varA\limits_{k = 1}^n$$, scriptscript: $$\scriptscriptstyle \sum\limits_{k = 1}^n \quad \varA\limits_{k = 1}^n$$.

In order to further align the upper and lower limits of self-defined operators with \sum, here is a way:

\DeclareMathOperator*{\varvarA}{%
\vphantom{\sum}\vcenter{\mathchoice{%
\LARGE\text{A}}{%
\Large\text{A}}{%
\Large\text{A}}{%
\large\text{A}}}}


Test: Display: $$\displaystyle \sum\limits_{k = 1}^n \quad \varvarA\limits_{k = 1}^n$$, text: $$\sum\limits_{k = 1}^n \quad \varvarA\limits_{k = 1}^n$$, script: $$\scriptstyle \sum\limits_{k = 1}^n \quad \varvarA\limits_{k = 1}^n$$, scriptscript: $$\scriptscriptstyle \sum\limits_{k = 1}^n \quad \varvarA\limits_{k = 1}^n$$.

• Concerning the display style, the height of the "A" in \LARGE is too small, and the height in \huge is too big. In other words, how could I make the limits under and above the "A" match the vertical alignment of the limits in the "\sum"? – sting890 Jul 14 at 10:08
• @sting890 The idea is to use \vphantom to get the same height of \sum. See my update. – Saad Jul 14 at 14:18