Take the 2-minute tour ×

I'm trying to write HMX_Y, and because someone out there (mr. or ms. TeX) thinks this is a math notation, I have to use verbatim function to convince him (or her) otherwise. So far I've been using examplep package and the command \Q{HMX_Y}. However I would like the text to be in the same style and font as the rest of the document (and not in typewriter style). Any tips how to do this?

This is the line where I'm trying to set the fonts to normal (as examplep documentation suggests) but I must be doing something wrong (as it's not working).

\usepackage[Q=yes, url=yes, source-verbatimfont=normalfont]{examplep}

Any help much appreciated.

share|improve this question
add comment

3 Answers

up vote 9 down vote accepted

Of course, you can also just type HMX\_Y when you're in text mode to get the underscore (which is even shorter than \Q{HMX_Y}!)

Probably you already knew that, and your question was about how not to type the \ before the underscore, but I still wanted to point out the most simple solution.

share|improve this answer
add comment

See http://www.tex.ac.uk/cgi-bin/texfaq2html?label=underscore

Short summary: in textmode you can use \textunderscore to get the underscore, but you should make sure to set your font encoding to T1 because the default encoding does not have the underscore character.

You can also use the underscore package here to simplify typing.

share|improve this answer
As mentioned in a few comments on other answers, the even easier way is to just type HMX\\_Y. The slash before the underscore tells TeX not to use it as a command character, but a literal one. –  Michael Underwood Jul 31 '10 at 17:49
\\_ and \textunderscore do not seem to have the same definition, BTW: \\_ is \x@protect \\_\protect \\_ while \textunderscore is \T1-cmd \textunderscore \T1\textunderscore. I don't know what this difference means. –  ShreevatsaR Jul 31 '10 at 19:06
add comment

Reading the documentation of the examplep package it seems that the option you actually need is


however, it doesn't work. The package complains that normalfont is not a valid option. Furthermore, even hacking into \pexa@@verbatimfont and redefining it to \normalfont doesn't work either, because (as Willie Wong pointed out) the default font encoding doesn't have an underscore character there!

Indeed, underscore is the package you're looking for, but you might want to consider submitting a bug report to the author of examplep nevertheless.

share|improve this answer
add comment

Your Answer


