I have defined a new command as a macro as follows:

\newcommand{\Sel}[3]{S_{#1}^{#2, #3}}

I want every invocation of this command to consist of teletypefont (\texttt) so I tried changing the macro to:

\newcommand{\Sel}[3]{\texttt{S_{#1}^{#2, #3}}}

This gives me the following errors in the lines where \Sel is used in my Tex file:

  • Missing $ inserted.
  • Extra }, or forgotten $.

Trying to do something such as follows in the Tex file gives similar errors as well:


I'm hoping this is me misunderstanding the usage of commands inside commands.

Any help would be appreciated.


  • Welcome to TeX.SX! You are trying to put a text command in math mode? Try the other way around (put some \mathtt in there). – TeXnician Oct 9 '17 at 17:50


Let us change your

\verb+\newcommand{\Sel}[3]{\texttt{S_{#1}^{#2, #3}}}+


\newcommand{\Sel}[3]{\mathtt{S_{#1}^{#2, #3}}}



enter image description here

As you can observe, \texttt is changed into \mathtt, which behaves properly in math mode.

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.