# Missing { / } inserted when using \texttt

I recently had to reinstall my tex environment (texlive under windows), and afterwards I got lots of "Missing { [or }] inserted" errors. I managed to track the cause down to the use of \texttt within subscript. More precisely, using pdflatex on the following minimal example

\documentclass{beamer}
\begin{document}
$A_\texttt{a}$
\end{document}


gives me the following errors:

Missing { inserted. $A_\texttt Missing } inserted.$A_\texttt{a}$ I guess something must have gone wrong with the fonts, but I can't figure out what. By the way, for this small example the pdf file is created correctly, but for larger files pdflatex aborts. Any suggestions? • Do you have a reason for not writing either $A_{\texttt{a}}$ or $A_{\mathtt{a}}$? – Mico Sep 1 '20 at 16:39 • Thanks for the tips. As for \mathtt{}, I'm actually using this string inside a command that can appear inside and outside of math mode, so I'd rather stick with \texttt. As for putting { } around it, I didn't know it was necessary. Any Idea why it worked previously, but not anymore? – Jan Sep 1 '20 at 16:45 • it was never supported behaviour but because the parsing of _ is very odd it sometimes works anyway, but any redefinition of texttt is likely to break it again. if _ took it's argument like a macro the braces would be needed, \fbox\texttt{a} would be \fbox{\texttt}{a} and fail badly. Sep 1 '20 at 16:49 • your example works in texlive 2018 but not 2019 or 2020 Sep 1 '20 at 16:53 • That figures, my previous texlive installation was a few years old. OK, thanks to both of you, guess I'll have to rewrite a few commands... – Jan Sep 1 '20 at 16:55 ## 1 Answer The suggestion is to use $A_{\mathtt{a}}$ or, if you really prefer, $A_{\texttt{a}}\$


Beware, though, that in an italic context, the latter would print the subscript in italics.

The error you get is specific to beamer, because it juggles with fonts in order to get as much sans serif as possible. It wouldn't appear with article or other document classes.

Anyway, the syntax A_\texttt{a} has never been officially supported and complex subscript should always be braced.

Some examples are

A_\sqrt{2}
A_\frac{1}{2}
A_\notin


The last example shows that not even a single token is safe. You can safely use unbraced a single letter or digit, with no formatting instruction. For symbols, use braces and you'll be OK. Hence

A_{\mathrm{a}}


is good, whereas A_\mathrm{a} is bad, even if it appears to work.