When using variable-size operators such as \prod
, \sum
, \bigcup
, and \bigcap
, their sizes are usually not quite predictable, which makes me pretty annoyed. I just want to make their sizes fixed throughout the document, e.g., the same vertical size as X_{1}^{1}
.
I tried to renew the definition of \prod
using \renewcommand
and scalerel package:
\renewcommand{\prod}{{\scalerel*{\prod}{X_{1}^{1}}}}
but it throws an error:
TeX capacity exceeded, sorry [grouping levels=255]. \prod
It should be allowed to use \limits
to put limits on the top and bottom of the symbol in display mode.
Any comment on this issue?
Edit:
I prepared an example demonstrating the issue:
\documentclass{article}
\usepackage{amsmath}
\usepackage{scalerel}
\newcommand{\set}[2]{\left\{{#1}~\middle|~{#2}\right\}}
\begin{document}
\begin{equation*}
\prod_{\alpha \in A} X_{\alpha}
=
\set{x \in A\to \bigcup_{\alpha\in A} X_{\alpha}}{\forall \alpha \in A: x_{\alpha} = x(\alpha) \in X_{\alpha}}
\end{equation*}
\begin{equation*}
\begin{array}{r@{~}l}
\prod_{\alpha \in A} X_{\alpha}
&=
\set{x \in A\to \bigcup_{\alpha\in A} X_{\alpha}}{\forall \alpha \in A: x_{\alpha} = x(\alpha) \in X_{\alpha}}\\
&=
\set{x \in A\to \bigcup_{\alpha\in A} X_{\alpha}}{\forall \alpha \in A: x_{\alpha} = x(\alpha) \in X_{\alpha}}
\end{array}
\end{equation*}
The above two equations show the inconsistent sizing of operators.
\newcommand{\prode}{\mathop{\scalerel*{\prod}{X_{1}^{1}}}}
\newcommand{\bigcupe}{\mathop{\scalerel*{\bigcup}{X_{1}^{1}}}}
The desired result is
\begin{equation*}
\begin{array}{r@{~}l}
\prode\limits_{\alpha \in A} X_{\alpha}
=
\set{x \in A\to \bigcupe\limits_{\alpha\in A} X_{\alpha}}{\forall \alpha \in A: x_{\alpha} = x(\alpha) \in X_{\alpha}}
\end{array}
\end{equation*}
\end{document}
In the last equation, I defined \prode
and \bigcupe
. But I just want to renew \prod
and \bigcup
. I think the error is caused by infinite loops.
Found solution:
I solved the problem by using \let
found in Can I redefine a command to contain itself?
\let\oldprod\prod
\renewcommand{\prod}{\mathop{\scalerel*{\oldprod}{X_{1}^{1}}}}
\let\oldbigcup\bigcup
\renewcommand{\bigcup}{\mathop{\scalerel*{\oldbigcup}{X_{1}^{1}}}}
Thank you!
Best Answer
The size is predictable and it follows the typographic traditions.
Anyway, here's a way to reduce the size in display style to be the same as in text style.
I take advantage from the fact that big operators are defined in a uniform way by
amsmath
, using a common template and the operator\xyz
refers internally to\xyz@
.The idea is to save the meaning of
\sum@
into\latex@sum
and then redefining\sum@
to meanso in display style we actually use the
\textstyle
version. With the help ofexpl3
trickery, we're able to do all the needed redefinitions at once with no code duplication.I also take the occasion to show how your definition of
\set
with\left
and\right
is not really good. For the expression you have\big
size is more than enough: already\Big
size is too much.