[Tex/LaTex] Controling underline depth in math mode

math-modetext-decorationsulem

I use the ulem package to control the depth of underlines by setting

\renewcommand{\ULdepth}{1pt}

This works fine outside math mode. However, when using \uline inside math mode, I seem to lose control over the underline depth. (Adding \smash doesn't really solve the problem either.)

\documentclass{article}

\usepackage[normalem]{ulem}
\setlength{\parskip}{15pt} % add space between paragraphs for illustration

\begin{document}

\renewcommand{\ULdepth}{1pt} 
\uline{normal text} $\uline{f(x)=y}$

\uline{normal text} $\uline{\smash{f(x)=y}}$

\renewcommand{\ULdepth}{10pt}
\uline{normal text} $\uline{f(x)=y}$

\end{document}

enter image description here

Is there a way to "regain control" over underline depth within math mode. If such control is not possible with the ulem package (I also tried with soul, which didn't work), are there other packages that can achieve the purpose of making the depth of underlines uniform both inside and outside math mode?

Best Answer

You can use $\mbox{\uline{$....$}}$ if you want to underline a subterm of the math with ulem text settings.