How to italicize superscripts and subscripts in math mode?

I'm pretty new in LaTeX, but I was surprised when in math mode subscripts and superscripts weren't italic. How can I solve this issue?

Here's my code:

$(Z(\bm{\mathrm{s}}\textsubscript{1}), ..., Z(\bm{\mathrm{s}}\textsubscript{n}))\textsuperscript{\mathit{T}}$


I'm talking about the "1", the "n" and the "T" characters. Thank you all.

• Welcome to TeX.SE! Oct 26 '21 at 14:19

As the name implies, the commands \textsubscript and \textsuperscript are used to typeset subscripts and superscripts in text mode, not in math mode. Indeed, compiling your code in the minimal document

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\begin{document}
$(Z(\bm{\mathrm{s}}\textsubscript{1}), ..., Z(\bm{\mathrm{s}}\textsubscript{n}))\textsuperscript{\mathit{T}}$
\end{document}


yields the error

LaTeX Error: \mathit allowed only in math mode. [...tsubscript{n}))\textsuperscript{\mathit{T}}]


because \mathit is a math command, whereas \textsuperscript expects its argument to be text.

To typeset subscripts and superscripts in math mode, you should use _ and ^ respectively. So your code should rather be something like the following.

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}
\begin{document}
$(Z(\bm{\mathrm{s}}_1), ..., Z(\bm{\mathrm{s}}_n))^T$
\end{document}


Then the "n" and the "T" are italic, as usual math characters.

• Thank you! Sorry for the banal error, I'm practicing with OverLeaf and I didn't see it. Oct 26 '21 at 15:54
• I'm glad that it helped you! :) If it solves your problem, you can mark the answer as "accepted", as explained in the help center. It helps to keep the site organized if the problem is solved. Oct 26 '21 at 16:10
• By the way, \bm{\mathrm{s}} is a complicated way to get \mathbf{s}. Oct 26 '21 at 16:12
• Overleaf is somewhat notorious for making errors a bit too hard to notice. Look for the red number above the pdf. Oct 26 '21 at 17:52
• Thank you all for the helpful advices! Oct 27 '21 at 7:17