TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to include some source files using \verbatiminput{}. Some of these filenames have underscores in them. This works fine by default. But if I try to include the underscore package so that I can use underscores in text and within \texttt{}, suddenly my verbatim input stops working (it tries to read the file specified by the name before the underscore, and it just prints out the text after the underscore). How can I fix this?

share|improve this question
up vote 3 down vote accepted

The documentation of the underscore package states that _ must be avoided in file names. However, if you do need to use an _ in the file name, there is the [strings] package option which along with the \UnderscoreCommands can be used to specify a list of commands where an _ is needed.

Below, I have added the command \verbatiminput to the this list -- the others are directly from the documentation. Note that this list must be defined before the package is loaded.


\do\citeNP \do\citeA \do\citeANP \do\citeN \do\shortcite%
\do\shortciteNP \do\shortciteA \do\shortciteANP \do\shortciteN%
\do\citeyear \do\citeyearNP%

\texttt{Am going to include the file a_b here}% This still produces the correct output
share|improve this answer

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.