This page states, falsely as far as I can tell, that the code

\texttt{\alpha in texttt mode }\alpha

results in this appearing in the document:

\alpha in texttt mode

followed by the letter alpha in math mode.

In fact I get this:

! Missing $ inserted.

How do I include a backslash or a tilde or a brace or any of many other characters that are not letters within texttt?

  • 2
    What you want is a verbatim presentation, which uses \ttshape and includes non-alphanumeric characters. The in-line form is \verb|...| where the "wrappers" should be a character not in the verbatim string. (+ is also often used.) The display environment \begin{verbatim} ... \end{verbatim} is also available. Commented Mar 10, 2023 at 19:49
  • 2
    \texttt{\textbackslash{}alpha in texttt mode }$\alpha$ Commented Mar 10, 2023 at 19:49
  • 3
    Indeed, the site you link contains a lot of nonsense...
    – campa
    Commented Mar 10, 2023 at 20:11
  • Possibly the inline version of "verbatim" is all that I needed. I hadn't realized that it has an inline version. Commented Mar 12, 2023 at 17:24

2 Answers 2


enter image description here

I recommend using listings package and define your style in which you use literate to define how special characters are handled. Check pages 51-52 of listings package documentation (v1.8d)


    basicstyle=\ttfamily, % font style and size
    *{\\}{{\textbackslash{}}}{1}, % \

    \lstinline|\alpha in texttt mode|

To get a true alpha in a typewriter font, use text fonts and text mode. Here's a simple solution using the babel support for the Greek language and exploiting the fact, that the Greek letter alpha is encoded as 'a':

\texttt{{\selectlanguage{greek}a} in text mode}

The ouput is

ouput of the LaTeX snippet above, showing a typewriter alpha in text mode

  • I didn't have any interest at all in getting a true alpha in typewriter font. That's not what my question is about. I do want to get a backslash and a tilde and various other characters found on the standard qwerty keyboard that texttt cannot normally handle. Commented Mar 11, 2023 at 23:35
  • Ah ... the answer to your comment is \begin{verbatim} and \end{verbatim}, or, for really short inserts, \verb:...:. All this is standard LaTeX without any packages, packages like fancyverb add a lot more bells and whistles to that. Commented Mar 13, 2023 at 9:13
  • But \begin{verbatim} and \end{verbatim} does not serve here, and that is why I asked. I thought that was obvious. Commented Mar 14, 2023 at 4:11

You must log in to answer this question.

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