0

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:

$\texttt{\Sel{x}{y}{z}}$

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

Any help would be appreciated.

Thanks.

  • 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
2
\documentclass{article}

\begin{document}

Let us change your

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

into

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

${\Sel{x}{y}{z}}$

\end{document}

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.