# Formatting of a star in the right upper corner of a product symbol [duplicate]

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:
$$\nonumber \prod_{i\in I}^\star$$
Second variant in equation is good:
$$\nonumber {\prod_{i\in I}}^\star \quad\text{but not completely:\quad} {\prod_{\text{long text under the symbol}}}^\star$$
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:

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

## marked as duplicate by egreg amsmath StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Oct 19 '18 at 13:37

• See also this question. – Karlo Oct 19 '18 at 13:34
• \newcommand{\sprod}{\sideset{}{^*}\prod} – egreg Oct 19 '18 at 13:38
• @egreg ...except that \sideset always seems to place things in \displaystyle. It also screws up subscript placement for inline usage. – Steven B. Segletes Oct 19 '18 at 13:44

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


• 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