0

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}}$

code_sub_sup

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

1
  • 1
    Welcome to TeX.SE!
    – Mensch
    Oct 26 '21 at 14:19
5

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.

5
  • 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.
    – Vincent
    Oct 26 '21 at 16:10
  • 2
    By the way, \bm{\mathrm{s}} is a complicated way to get \mathbf{s}.
    – egreg
    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.
    – Teepeemm
    Oct 26 '21 at 17:52
  • Thank you all for the helpful advices! Oct 27 '21 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.