views:

1683

answers:

5

How can you escape _ without the use of \_?

This is the example of the question

word_a_a_a_a_a_b_c_dd

There is one function which you can use for this. However, I cannot remember its name.

+7  A: 

Are you thinking of the underscore package, which redefines the underscore symbol so that you don't have to escape it in text mode? See here.

John Feminella
Thank you for pointing that out! I will use this package in my next procject, since my current code breaks because it contains a lot of underscores espaces by `\_`.
Masi
+2  A: 

Other than verbatim I wouldn't know.

Verbatim environment:

\begin{verbatim}
  word_a_a_a_a_a_b_c_dd
\end{verbatim}

Inline:

\verb|word_a_a_a_a_a_b_c_dd|
Martijn
A: 

You may also be thinking of the lstlisting or verbatim environments, which are commonly used to display code - which can contain underscores. However, these environments do a lot more than just "escape" underscores.

Eamon Nerbonne
+1  A: 

I couldn't get the underscore package to work, so I used the url package:

\usepackage{url}
\urlstyle{sf}  % or rm, depending on your font

...

Foo \url{word_a_a_a_a_a_b_c_dd} bar.
Vebjorn Ljosa
A: 

Typically you want a monospaced font in such situations, so you can use this:

\verb|word_a_a_a_a_a_b_c_dd|
Peter