help me write verbatim

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.

-

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.

-

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.

-
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

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

``````pverb-verbatimfont=normalfont
``````

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.

-