MWE:
\documentclass{article}
\usepackage{xcolor}
\begin{document}
$M_{\theta}$ % correct size theta
$M_{\rlap{\ensuremath{\theta}}}$ % too large theta
\end{document}
Why does this happen? How can I fix it? In my case the \rlap is inisede a command that I would like to work inside and outside of supscripts and superscripts:
\documentclass{article}
\usepackage{xcolor}
\newcommand{\rlaptheta}{\rlap{\ensuremath{\theta}}} % I would like the command to work both in normal mode as well as in subscript or superscruit
\begin{document}
$M_{\theta}$ % correct size theta
$M_{\rlap{\ensuremath{\theta}}}$ % too large theta
$M_{\rlaptheta}$ % too large theta
$\theta\rlaptheta$ %correct size
%The same for superscripts
$M^{\theta}$ % correct size theta
$M^{\rlaptheta}$ % too large theta
\end{document}

\rlapis thought to be for text and does not scale in subscripts. Use\mathrlapfrom themathtoolspackage. – campa Nov 16 '23 at 13:54\rlapis\def\rlap#1{\hbox to 0pt{#1\hss}}. Note that the<stuff>inM_{\hbox{$<stuff>$}}won't get subscript size unless you specify\scriptstyleexplicitly. – Stephen Nov 16 '23 at 13:59