# How can I make a math operator symbol be bigger in display math?

I have an operator $\boxplus$ that works on an indexed collection of arguments, similar to $\sum$ or $\prod$ or $\bigoplus$.

The following makes the index ranges typeset nicely:

\usepackage{amsopn}
\DeclareMathOperator*{\op}{\boxplus}


But the size is still fixed, which looks wrong, especially in displaymath:

 $\sum_{i=1}^3 x_i \quad \bigoplus_{i=1}^3 x_i \quad \op_{i=1}^3 x_i$
$$\sum_{i=1}^3 x_i \quad \bigoplus_{i=1}^3 x_i \quad \op_{i=1}^3 x_i$$


How can I make appropriate sizes be used for inline math and displaymath, like what happens automatically with $\sum$ and $\prod$ and $\bigoplus$?

One option using \mathchoice:

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

\newcommand{\op}{
\mathop{
\vphantom{\bigoplus}
\mathchoice
{\vcenter{\hbox{\resizebox{\widthof{$\displaystyle\bigoplus$}}{!}{$\boxplus$}}}}
{\vcenter{\hbox{\resizebox{\widthof{$\bigoplus$}}{!}{$\boxplus$}}}}
{\vcenter{\hbox{\resizebox{\widthof{$\scriptstyle\oplus$}}{!}{$\boxplus$}}}}
{\vcenter{\hbox{\resizebox{\widthof{$\scriptscriptstyle\oplus$}}{!}{$\boxplus$}}}}
}\displaylimits
}

\begin{document}

\begin{gather*}
\end{gather*}

\end{document}


Mostly equivalent macros with \mathpalette, that avoids code duplication. There are other small fixes.

\makeatletter
\newcommand*{\op}{%
\DOTSB
\mathop{\vphantom{\bigoplus}\mathpalette\matt@op\relax}%
\slimits@
}
\newcommand\matt@op[2]{%
\vcenter{\m@th\hbox{\resizebox{\widthof{$#1\bigoplus$}}{!}{$\boxplus$}}}%
}
\makeatother

• Two suggestions: (i) Use \vcenter{\hbox{...}} instead \raisebox{<offset amount>}{...}. (ii) For the scriptstyle and scriptstyle cases, use \oplus rather than \bigoplus in the \widthof calculations. – Mico Sep 23 '15 at 3:12
• @Mico Both suggestions incorporated. Thanks. – Gonzalo Medina Sep 23 '15 at 17:11
• Add also \vphantom{\bigoplus} as the limits are badly placed in the current version. – egreg Sep 23 '15 at 17:25

For simple geometric shapes, picture mode is invaluable:

\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e}

\makeatletter
\newcommand*{\bigboxplus}{\DOTSB\mathop{\mathpalette\big@boxplus\relax}\slimits@}

\newcommand{\big@boxplus}[2]{%
\vcenter{%
\m@th\bigbox@thickness{#1}%
\sbox\z@{$#1\bigoplus$}%
\hbox{%
\setlength{\unitlength}{\dimen@}%
\begin{picture}(1,1)
\polyline(0.1,0.1)(0.9,0.1)(0.9,0.9)(0.1,0.9)(0.1,0.1)(0.5,0.1)
\polyline(0.5,0.1)(0.5,0.9)
\polyline(0.1,0.5)(0.9,0.5)
\end{picture}%
}%
}%
}

\newcommand{\bigbox@thickness}[1]{%
\ifx#1\displaystyle
\linethickness{0.2ex}%
\else
\ifx#1\textstyle
\linethickness{0.16ex}%
\else
\ifx#1\scriptstyle
\linethickness{0.12ex}%
\else
\linethickness{0.1ex}%
\fi
\fi
\fi
}
\makeatother

\begin{document}

\begin{gather*}