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 am trying to use listings to point to a Java source code file. The file path is different from the Latex document. Below is an example of what I am trying to do, though it doesn't compile it says it can't find the file. How would I point to my file or do the source code files need to be in the root latex folder?





\section{Appendix A: Application Code}
share|improve this question
I think as a safety feature, you are not allowed to point to parent directories of your tex source file. you could probaly use the import package though – Martin H Apr 23 '12 at 18:49
up vote 3 down vote accepted

Normally latex happily reads listings from any directory. For example, this document:

\section{Appendix A: Application Code}

happily typesets 22 pages of GNU stdlib.h on my system.

So one of several things might happen:

  1. You might have a typo in the file path.
  2. The path might have a space - TeX really does not like them.
  3. You might not have permission to read the file.

Try the example above on a Unix system (or an equivalent on a non-Unix one) to see whether listings can read the file which is definitely present and readable.

share|improve this answer
There was a typo by me which is annoying and there was a space in one of the folder names fixed and working now though. Thanks – Arran Apr 23 '12 at 19:42

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.