The problem can be seen with this very small MWE:
\documentclass[a4paper]{article}
\uccode`@=`I \lccode`@="10
\usepackage{listings}
\lstset{
language = Java,
basicstyle=\scriptsize\ttfamily,
}
\begin{document}
\begin{lstlisting}
... InterruptedException {
}
\end{lstlisting}
\end{document}
The \uccode`@=`I \lccode`@="10
line is found at the very end of metu.cls
, and it apparently messes up listings
. Remove the line, and the {}
reappear.
Instead of \java
, I would define an environment java
. Then the \begin
and \end
macros are properly matched in the source code, also making some TeX editors happy. Such an environment is defined by \lstnewenvironment
of package listings
. Also an optional argument is added. Then the user can set some options in \begin{java}[...]
for a particular listings.
The \incjava
command should work as is does in the following example. Also this macro is given an optional argument for options to the particular listings.
\documentclass{article}
\usepackage{listings}
\lstnewenvironment{java}[1][]{%
\lstset{language=Java,#1}%
}{}
\newcommand*{\incjava}[1][]{%
\lstinputlisting[{language=Java,#1}]%
}
\begin{document}
\begin{java}
public class Example implements StringHandler {
/**
* Prints the given string.
*
* @param s the given string
*/
@Override
public void handle(String s) {
System.out.println(s);
}
}
\end{java}
\incjava{Example.java}
\end{document}
There is no \listingspath
for listing files, but \input@path
for TeX files can be defined, e.g.:
\makeatletter
\providecommand*{\input@path}{}
\g@addto@macro\input@path{{code/openglprocessing/}}
\makeatother
Each entry should be surrounded by curly braces and end with the directory separator.
Another variant is setting the environment variable TEXINPUTS
to include the directory, example for TeX Live/Linux:
TEXINPUTS=:code/openglprocessing
The colon (Unix) or semicolon (Windows) at the beginning is important, because then the previous search path (from texmf.cnf
) is added at this place.
Best Answer
Normally
latex
happily reads listings from any directory. For example, this document:happily typesets 22 pages of GNU
stdlib.h
on my system.So one of several things might happen:
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.