2

I'm trying to get a star in the right upper corner of a product symbol:

\documentclass{article}    
\usepackage{amsmath}    
\begin{document}
First variant in equation is bad:
\begin{equation}\nonumber
\prod_{i\in I}^\star
\end{equation}
Second variant in equation is good:
\begin{equation}\nonumber
{\prod_{i\in I}}^\star
\quad\text{but not completely:\quad}
{\prod_{\text{long text under the symbol}}}^\star
\end{equation}
First variant inline is good: $\prod_{i\in I}^\star$ and the second is bas: ${\prod_{i\in I}}^\star$.
\end{document}

Here a picture:

enter image description here

How can I put this logic in a new command? And of course also solve the problem with the long text in equation.

PeptideChain
  • 1,335

1 Answers1

1
\documentclass{article}    
\usepackage{mathtools}
\newcommand\prodstar{\mathop{{\prod\nolimits^{\mathrlap{\star}}}}}
\begin{document}
Prodstar in equation is good:
\begin{equation}\nonumber
\prodstar_{i\in I}
\qquad\text{smaller styles:}\qquad
\scriptstyle \prodstar_{i\in I}\qquad
\scriptscriptstyle \prodstar_{i\in I}
\end{equation}
Prodstar is still good:
\begin{equation}\nonumber
\prodstar_{i\in I}
\quad\text{yes, completely:\quad}
\prodstar_{\text{long text under the symbol}}
\end{equation}
Prodstar inline is good: $\prodstar_{i\in I}$ and in the second case: $\prodstar_{i\in I}$.
\end{document}

enter image description here

  • thank you for the exhaustive answer and some humour that makes it even better – PeptideChain Oct 19 '18 at 16:57
  • @PeptideChain The only issue that can arise is if you intend to use it with superscripts. In displaystyle, the limit will sit a little high (that can be fixed by \smashing the \mathrlap), in the smaller math styles, the superscript will clash with the star, unless space is manually added. – Steven B. Segletes Oct 19 '18 at 16:59