5

I'm trying to display the following:

.\integrate blah

in a monospaced font.

For everything else I've wanted to put in a monospace font, \texttt or \verb has worked fine, but it doesn't with this. I've worked out that I need to escape the \ in the text, but replacing it with \\ gives a newline.

What should I use to escape the \ in LaTeX?

  • 1
    \verb+\integrate+ works OK. – Gonzalo Medina Mar 7 '11 at 17:00
  • Is that trying to display an integration sign? I'm trying to display the actual text "integrate". – robintw Mar 7 '11 at 17:04
  • No. \verb+\integrate+ will display "\integrate" in a monospaced font. – Gonzalo Medina Mar 7 '11 at 17:18
10

You can use \verb to display a backslash in monospaced font; the following example shows another option to display a backslash in monospaced font:

\documentclass{article}

\begin{document}

\verb+\+

\texttt{\symbol{92}}

\verb+\integrate+

\texttt{\symbol{92}integrate}

\end{document}
7

You could use \textbackslash to produce a backslash. To get it monospaced, you should use T1 font encoding which is recommendable anyway, otherwise it's not a true typewriter backslash.

You might also have a look at answers to these questions:

Compare:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{url}
\begin{document}
\verb|.\integrate|

\texttt{.\textbackslash integrate}

\texttt{.\char`\\integrate}

\path{.\integrate}
\end{document}

backslash screenshot

  • but \textbackslash will not produce a backslash in monospaced font. – Gonzalo Medina Mar 7 '11 at 17:20
  • @Gonzalo: it produces a monospaced backslash in T1 encoding, which is very recommendable. You're right, with the default (OT1) encoding the backslash would be in another font. I will add that restriction to the answer. – Stefan Kottwitz Mar 7 '11 at 17:38
1
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{url}
\DeclareUrlCommand\cs{\ttfamily.\textbackslash}
\begin{document}

\cs{integrate}

\end{document}

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.