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.

How can I produce the text Word_one_two in LaTeX?

I tried:


But, it doesn't quite look right. Also, I want it in the typewriter font, so actually, I'm doing:


I find it looks a bit like the underscore is merging in to the bottom of the "D", but maybe it's just because of the typewriter D?

share|improve this question
This reminds me of one of my pet peeves : all these unneeded special characters in the text mode. If you use the underscore package, then you don't need to escape the _ in text mode. FWIW, in ConTeXt, _ has a letter catcode in text mode, so simply typing Samp_Distt_Corr works. –  Aditya Mar 20 '12 at 3:17
underscore works, but Vim still highlights it as an error. To avoid, edit vimXX/syntax/tex.vim: texOnlyMath "[_^]" becomes "[\^]". –  Evgeni Sergeev Jul 16 '13 at 4:40
Hmm, an annoyance with the underscore package is that it's not bold in \textbf{a_b}. –  Evgeni Sergeev Jul 30 '13 at 7:34
A greater annoyance is that one cannot \includegraphics{filename_with_underscore} when the underscore package is used. –  Evgeni Sergeev Aug 1 '13 at 2:27
The solution I've settled on was to \usepackage[Q=yes,pverb-linebreak=no]{examplep} and then \Q{identifier_typeset_in_monospace}. This suits me, because all my underscores occur in code: variables, function names, filenames, etc., all of which could be typeset in a verbatim-like environment. –  Evgeni Sergeev Aug 23 '13 at 4:00

5 Answers 5

up vote 38 down vote accepted

You may prefer the character from the tt font:






enter image description here

Or probably better add \usepackage[T1]{fontenc} then all the above forms will use the character from the font.

share|improve this answer
I wonder why when _ is used in text mode LaTeX is not smart enough to send it to output directly? –  PHPst Oct 11 '13 at 18:23
@PHPst This is not LaTeX it is very low level TeX behaviour and in general TeX doesn't do such switches, compare the behaviour of say \alpha also in the original TeX OT1 encoded TeX fonts, they typically didn't have a _ character so it isn't clear what "output directly" means, choice of switching to tt which did have, or using a rule or... –  David Carlisle Oct 11 '13 at 18:27
' it isn't clear what "output directly" means,...' It could simply consider it similar to all other characters by default in non-math mode. –  PHPst Oct 12 '13 at 5:11
@PHPst in the standard OT1 encoding, that wouldn't be useful try setting \catcode`\_=12 (to make it a standard punctuation character) and you'll seee that unless in tt font you get a dot accent, same as < and > are not useful out of text mode and give spanish punctuation inverted ! and ? –  David Carlisle Jan 5 '14 at 2:17

You can use \textunderscore also.

Samp\textunderscore Distt\textunderscore Corr

\texttt{Samp\textunderscore Distt\textunderscore Corr}

enter image description here

Underscore is not merging at the bottom of D actually. It is very close to it.

share|improve this answer
That \textunderscore thing didn't actually work for me: The underscore symbol \texttt{\char`_} is a special variable that contains the result of the last printed value. The underscore symbol \texttt{\textunderscore} is a special variable that contains the result of the last printed value. produces minireference.com/static/textunderscore_not_shown_well.png –  ivan Jul 22 '14 at 16:37

A fairly elementary way of stripping special meaning from things is to \detokenize them:

enter image description here


\texttt{\detokenize{a@b\c_d&e~f g}}

Note how a space is inserted after a "control sequence". See What are the exact semantics of \detokenize?

share|improve this answer

The easiest way to have an occasional underscore in text mode (without need to reprogram the whole Matrix...) IMHO is as following:


James\underline{{ }{ }}Bond

which produces a nice James_bond, with a correct spacing between letters

I hope it'll help you.

share|improve this answer

I was looking to get the underscore character inside a word in any font, and Google brought me here, so here's the solution I found:





share|improve this answer
This is already covered in the other answers. –  Werner Sep 23 '14 at 2:11
Which answer covers this? All the other answers refer to tt, detokenize, textunderscore, and using underline. –  dantiston Sep 23 '14 at 4:12
The original post asks for a typewriter font solution, which is provided in David's answer. Since it also works in other fonts, it makes this answer no different than his. –  Werner Sep 23 '14 at 4:40
Alright -- I'll edit my answer to show that I found this page by looking for "underscore character in word latex" to note the relevance of this answer to other fonts. –  dantiston Sep 23 '14 at 16:34
@dantiston I'm not sure in what sense do you think this is different from what the question says. I'm with Werner, I think this answer doesn't add anything. –  Manuel Sep 23 '14 at 18:29

Your Answer


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.