Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
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

3 Answers 3

up vote 10 down vote accepted

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}
share|improve this answer

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

share|improve this answer
    
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
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{url}
\DeclareUrlCommand\cs{\ttfamily.\textbackslash}
\begin{document}

\cs{integrate}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.