Avoid italicizing text inside math inside theorem-like environments

I strongly suspect this is a duplicate but just could not find it answered.

Specific example: I need a 1/2 in subscripts and I use _{\text\textonehalf} for that purpose (\textonehalf is from the textcomp package). But inside theorems it becomes italicized, which I would like to avoid.

Is there a canonical way to handle this?

Here is a mwe

\documentclass{amsart}

\usepackage{textcomp}

\usepackage{amsthm}

\newtheorem{Theorem}{Theorem}

\begin{document}

\begin{Theorem}
Theorem-like environments make $x_{\text\textonehalf}$ look ugly.
\end{Theorem}

\begin{proof}
Look how cool does it look outside of them: $x_{\text\textonehalf}$!
\end{proof}

\end{document}


• \text explicitly asks for the outer text font, perhaps \textup is what you are looking for. – David Carlisle Jun 15 '20 at 13:31
• and now you know why \text is the wrong command to use. (there are so many users who apply \text as a big hammer to solve every problem) – daleif Jun 15 '20 at 14:22
• @daleif I am curious to know what you mean, but I cannot tell at all from what you wrote. Is there a better way to get text into math environments than \text? – Colin McLarty Aug 16 '20 at 18:04
• As David mentions \text is the wrong command to use. Here you want the subscript to always be upright. But that is not what \text does. It typeset its contents in the font front outside math. In the theorem, the font outside math is italics and thus the output of \text is italics. Do you see my point. As I also mention you're not the first person to do this mistake. IMO this misuse is one of the most common – daleif Aug 16 '20 at 18:08
• Okay, you just mean \text is the wrong tool here. – Colin McLarty Aug 16 '20 at 18:28

If I understood your question, you are looking for some way to make subscript fractions look nice. Therefor I would suggest using the nicefrac package and/or xfrac package.

You can find some explanation here

\documentclass{amsart}
\usepackage{amsthm}
\usepackage{xfrac}

\newtheorem{Theorem}{Theorem}

\begin{document}

\begin{Theorem}
Theorem-like environments make $x_{\sfrac{1}{2}}$ look awesome with another package.
\end{Theorem}

\end{document}

• Thank you! The solution you propose is entirely satisfactory. It is worth accepting, I am just waiting - maybe somebody proposes something which works more generally for any kind of text-inside-math, as in a comment by @DavidCarlisle above – მამუკა ჯიბლაძე Jun 15 '20 at 14:33