I am writing my reports which need to reference complete *.java files with latex. I am using the Texlipse Eclipse plugin to do the editing.
Right now I am referencing the complete path to each *.java file within the *.tex file like so:
\subsection*{Foo-class}
\lstinputlisting{/home/pathtoexlipse/workspace/Foo.java}
Since we are collaborating on the source files and the documentation with help of a VCS, it would be nice to have a means to reference a relative path within the latex document.
The folder structure within the project-file always looks like this:
Project_Folder/
|src/
|---Foo.java
|---Bar.java
|latex_documentation/
|--mydocument.tex
But since editing takes place under different systems, where the project-files are located at different absolute path on the filesystem, it would be nice to have a possibility to just reference the relative path when invoking \lstinputlisting
.
Also, it would be great, if it would be possible to automatically parse a directory for all *.java files, and automatically include them within the \lstinputlisting
.
Is there a means in latex to achieve these desired features?
\write18
to execute commands on the system, but this is generally considered unsafe and thus disabled by default. You can enable it by passing arguments like -shell-escape to pdflatex. I think it's better to run something outside of latex to generate the file listing that you can parse in TeX.\lstinputlisting{Foo.java}
.