I am typing a file where I often have to write $T_{\text{area}}$. But the command for adding text in a subscript is quite long when I have to write it all the time. Do anyone have any tips on a newcommand that could simplify this, for example where I can type T_area and that gives me the correct format?

I tried to use


but it does not work. Also It would be nice to generalize it for all texts, not ony "area".

  • 3
    You can't (easily) use an underscore in a macro name; just letters. Use \Tarea and it'll work. (Notice the backslash).
    – Rmano
    Aug 28, 2022 at 7:45
  • 3
    newcommand needs a command starting \ so \newcommand\Sarea{S_{\mathrm{area}}} Aug 28, 2022 at 7:46
  • 1
    Unrelated, as David show don't use \text for this, it does not do what you think.
    – daleif
    Aug 28, 2022 at 8:50

1 Answer 1


The instruction


is faulty for two separate reasons. First, TeX macros should generally start with a \ (backslash) character. (Well, there is the \csname ... \endcsname possibility; however, that's clearly not what you're concerned with.) Second, TeX control sequences should consist of either one or more lowercase and uppercase alphabetical letters (also known as a to z and A to Z...) or exactly one non-letter character. Examples of non-letter control sequences are \,, \!, \_, \$, \%, \\, etc.

Building on these two insights, the alternative definition


is valid -- but only from a purely syntactical point of view. As the comments posted below the query have already pointed out, the output of the \text macro is not as robust as you may think it is. Try executing $\Tarea$ \textit{$\Tarea$} \textsc{$\Tarea$} \texttt{$\Tarea$} and be prepared to be surprised. If you want the subscript material to be typeset exclusively in the upright shape of the document's main text font, give


a try. Of course, you are entirely free to choose a different macro name.

Also It would be nice to generalize it for all texts, not ony "area".

Using some unavoidable LaTeX jargon, this objective may be achieved by specifying that \TareaX takes an optional argument with default value area:


A final remark: Since the TeX-special character _ occurs in the definitions of the macros \Tarea and \TareaX, TeX will issue a (possibly mysterious) warning or error message if these macros are not used while inside math mode.

enter image description here

\usepackage{amsmath} % for \text macro

\newcommand\Tarea{S_{\text{area}}} % problematic
\newcommand\TareaX[1][area]{S_{\textnormal{#1}}} % fine

$\Tarea$ \textit{$\Tarea$} \textsc{$\Tarea$} \texttt{$\Tarea$} --- not good

$\TareaX$ \textit{$\TareaX$} \textsc{$\TareaX[volume]$} \texttt{$\TareaX[length]$} --- good
  • 2
    Extra +1 for the \text explanation
    – daleif
    Aug 28, 2022 at 13:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .