# How can I define a big plus operator that works like \bigcup?

I want to define a "\bigplus" operator that is a big + symbol that changes size according to environment and has limits, just like \bigcup works. I've read about defining a "\bigtimes" (How can I get a big cross to denote a generalized cartesian product?) but the answer doesn't help me since in package mathabx there's no "\bigplus" command and the package changes many symbols. I found the package mathtools, which has the command \bigtimes, but also no "\bigplus". I found in its source code the command

\def\MH_bigtimes_scaler:N #1{%
\vcenter{\hbox{#1$\m@th\mkern-2mu\times\mkern-2mu$}}}
\def\MH_bigtimes_inner: {
\mathchoice{\MH_bigtimes_scaler:N \huge}         % display style
{\MH_bigtimes_scaler:N \LARGE}        % text style
{\MH_bigtimes_scaler:N {}}            % script style
{\MH_bigtimes_scaler:N \footnotesize} % script script style
}
\def\MH_csym_bigtimes: {\mathop{\MH_bigtimes_inner:}\displaylimits}
\AtBeginDocument{
\providecommand\bigtimes{\MH_csym_bigtimes:}
}


and tried to copy it, changing \times for + or plus when necessary, and then pasted it in my preamble, but it does not work. If I copy it under the code itself it works, but I don't want to change the code, obviously. I'm looking for a way to define operator commands in general from symbols I already have, like +, since that would help me a lot.

• Note, however, that the mathabx package does provide a \bigplus command. – GuM Oct 7 '17 at 0:56
• You are right, I was mistaken. Actually mathtools does not. I've emailed them asking for the command but I believe they didn't get the email. – Pedro G. Mattos Oct 7 '17 at 5:02

A rip-off of my answer at How are big operators defined?. Two completely separate macros are provided (\foo and \barr), depending on whether one wishes the \displaystyle version to grow bigger or stay the same size as \textstyle.

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator*{\foo}{\scalerel*{+}{\sum}}
\DeclareMathOperator*{\barr}{\scalerel*{+}{\textstyle\sum}}
\usepackage{scalerel}

\begin{document}
$\foo_{i=3}^{6}(f^2(i))$

This is inline: $$\foo_{i=3}^{6}(f^2(i))$$

$\barr_{i=3}^{6}(f^2(i))$

This is inline: $$\barr_{i=3}^{6}(f^2(i))$$
\end{document}


One can easily make the “big plus” the same size as \sum:

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

\makeatletter
\newcommand{\bigplus}{%
\DOTSB\mathop{\mathpalette\mattos@bigplus\relax}\slimits@
}
\newcommand\mattos@bigplus[2]{%
\vcenter{\hbox{%
\sbox\z@{$#1\sum$}%
\resizebox{!}{0.9\dimexpr\ht\z@+\dp\z@}{\raisebox{\depth}{$\m@th#1+$}}%
}}%
\vphantom{\sum}%
}
\makeatother

\begin{document}

\begin{center}% test bounding box
\setlength{\fboxsep}{0pt}
\fbox{$\displaystyle\sum$} \fbox{$\displaystyle\bigplus$}
\end{center}

$\sum_{i=1}^m\bigplus_{j=1}^n\dots\bigplus_{k=1}^p x_{ijk}$
\begin{center}% to test text style
$\sum_{i=1}^m\bigplus_{j=1}^n\dots\bigplus_{k=1}^p x_{ijk}$
\end{center}

\LARGE % test for sizes
$\sum_{i=1}^m\bigplus_{j=1}^n\dots\bigplus_{k=1}^p x_{ijk}$
\begin{center}% to test text style
$\sum_{i=1}^m\bigplus_{j=1}^n\dots\bigplus_{k=1}^p x_{ijk}$
\end{center}

\end{document}


• Wow, that's a good answer, thank you. What are the differences between this and @Steven B. Segletes 's answer, apart from avoiding using scalerel package? Is this how the package does it? I tried both and dots, limits and rescaling seem to work fine. – Pedro G. Mattos Oct 7 '17 at 5:20
• One of a great suggestion egreg, you always a master... – MadyYuvi Oct 7 '17 at 5:48
• @PedroG.Mattos There is a single command, not two. – egreg Oct 7 '17 at 6:36
• @egreg To clarify, I do not require two commands. Rather, I provided 2 options to the OP, and he can choose which one of the two he prefers. – Steven B. Segletes Oct 7 '17 at 12:24
• @MadyYuvi Because egreg uses lower level commands to achieve the result, his is no doubt more efficient, whereas mine goes through the scalerel package. If there is an advantage to mine, it is easier to type the definition (and maybe, for a novice, easier to adapt the definition to suit similar needs). In both cases, we support the smaller (script and scriptscript) math styles. In both cases, we scale a box containing a + to the proper size. In both cases, we handle limits and surrounding space in accordance with the requirements of a \mathop. – Steven B. Segletes Oct 7 '17 at 12:27

You cannot copy LaTeX3 code into your preamble without taking appropriate preliminary actions. I’m showing below how the same idea could be implemented through LaTeX2e code. This solution also supports standard amsmath behavior with respect to dots and the [no]sumlimits option:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}

\makeatletter

\newcommand*\@bigplus[1]{\vcenter{\hbox{#1$\m@th +$}}}
\newcommand*\bigplus{%
\DOTSB % omit this line if you are not using the amsmath package
\mathop{%
\mathchoice
{\@bigplus \huge}%
{\@bigplus \LARGE}%
{\@bigplus {}}%
{\@bigplus \footnotesize}%
}%
\slimits@ % omit this line if you are not using the amsmath package
}

\makeatother

\begin{document}

In-line: $$\bigplus_{i=3}^{6} f^2(i)$$.
Displayed: $\bigplus_{i=3}^{6} f^2(i)$
Behavior with dots:
$\bigplus_{i_{1}=0}^{n_{1}}\dots\bigplus_{i_{k}=0}^{n_{k}} f(i_{1},\dots,i_{k})$

\end{document}


This is the output:

As @egreg has pointed out in his comment, the above answer—which, however, merely mimics what the mathtools package does for \bigtimes—is buggy. The correct solution is to use the mathabx package, which, contrary to what is stated in the question, does provide the \bigplus “large operator”. This solution uses characters drawn from fonts specifically designed for the purpose and, hence, does not depend on the extensions provided by the graphics/graphicx package; in particular, it works also with DVI output (for what this is worth).

If you don’t like the changes that the mathabx package applies to mathematical symbols in general, you can always load the appropriate fonts yourself and define only the commands you are interested in. The following example defines \bigplus as well as \bigtimes. Allow me a few remarks:

• the code supports the features of the amsmath package concerning dots and “limits”, if that package is loaded;

• contrary to what the mathabx package itself does, the mathx font family is defined in such a way to take advantage of the smaller font sizes installed in today’s distributions.

The latter contrivance permits to improve the output at sizes smaller than 10 points, making it look better than it does in solutions that use graphics scaling.

Here is the code:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath} % comment out to see changes

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<5> <6> <7> <8> <9> <10> gen * mathx
<10.95> mathx10
<12> <14.4> <17.28> <20.74> <24.88> mathx12
}{}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareMathSymbol{\bigplus} {\mathop}{mathx}{"90}
\DeclareMathSymbol{\bigtimes}{\mathop}{mathx}{"91}

\makeatletter

\@ifundefined{coprod@}{}{
\typeout{*** Applying amsmath patches to \protect\bigplus\space
and \protect\bigtimes. ***}
\global\let\bigplus@\bigplus
\gdef\bigplus{\DOTSB\bigplus@\slimits@}
\global\let\bigtimes@\bigtimes
\gdef\bigtimes{\DOTSB\bigtimes@\slimits@}
}
}{}

\makeatother

\begin{document}

In-line: $$\bigplus_{i=3}^{6} f^2(i)$$.
Displayed: $\bigplus_{i=3}^{6} f^2(i)$
Behavior with dots:
$\bigplus_{i_{1}=0}^{n_{1}}\dots\bigplus_{i_{k}=0}^{n_{k}} f(i_{1},\dots,i_{k})$

In-line: $$\bigtimes_{i=3}^{6} f^2(i)$$.
Displayed: $\bigtimes_{i=3}^{6} f^2(i)$
Behavior with dots:
$\bigtimes_{i_{1}=0}^{n_{1}}\dots\bigtimes_{i_{k}=0}^{n_{k}} f(i_{1},\dots,i_{k})$

Now it works in footnotes too.\footnote{As this example shows.
In-line: $$\bigplus_{i=0}^{n} f(i)$$, $$\bigtimes_{i=0}^{n} f(i)$$.
Displayed: $\bigplus_{i=0}^{n} f(i) \ne \bigtimes_{i=0}^{n} f(i)$
That's good!}

\LARGE
\verb|\LARGE| text.
In-line: $$\bigtimes_{i=3}^{6} f^2(i)$$.
Displayed: $\bigtimes_{i=3}^{6} f^2(i)$
Behavior with dots:
$\bigtimes_{i_{1}=0}^{n_{1}}\dots\bigtimes_{i_{k}=0}^{n_{k}} f(i_{1},\dots,i_{k})$

\end{document}


And here is the output it yields:

• This won't scale properly at different sizes. – egreg Oct 6 '17 at 21:38
• Of course, @egreg’s remark applies to mathtools’s \bigtimes as well. Indeed, I would regard this as a bug. – GuM Oct 7 '17 at 0:13