[Tex/LaTex] How to escape curly braces within \texttt{}

bracestypewriter

How can I escape curly braces within the \texttt{} environment?

\texttt{ \{ } produces errors within my template, which can be found here: (link)

I saw this question for square braces, but the solution seems like a bit of a hack, and doesn't work for curly braces.

(FYI, the purpose of this is to include a regex statement in monospaced font, among normal font in the rest of a table. If there's a preferable solution, I'm open to ideas there.)

Best Answer

For "escaping" one typically use \, as in \{ and \}. However, for the typewriter font, you might be interested in \string{ and \string}:

enter image description here

\documentclass{article}
\begin{document}
Compare \texttt{\string{\string}} to \verb|{}| and \texttt{\{\}}
\end{document}

\string provides similar output to \verb, but is allowed in moving arguments.

Related Question