Problem with relative paths in Listings package.

1,201 views
Skip to first unread message

AdCs

unread,
May 28, 2012, 8:44:14 PM5/28/12
to latexus...@googlegroups.com
Hi,

I'm using the listings package to show source code. I have the source code in a directory named src and the tex file in another directory.

I have also declared a new command for working with source code:
  \newcommand{\codigo}[3]{
    \lstinputlisting[float,caption={#2},label={src:#3}]{#1}
  }

When I do \codigo{../src/main.cpp}{OneCaption}{OneLabel} in the tex file this happens: ! Package Listings Error: File `../src/main(.cpp)' not found

The error also appears if I do \lstinputlisting{../src/main.cpp}, but if I use absolute paths, everything goes fine.

Is there a way to use relative paths to show the source code? Absolute paths to aren't very flexible :(

Thanks!


Ole Peter Smith

unread,
May 28, 2012, 8:58:22 PM5/28/12
to latexus...@googlegroups.com

In the directory where yousef run latex, can yousef 'ls' (dir on windows) the files yousef try to include?

0le

Send via Android

--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To view this discussion on the web visit https://groups.google.com/d/msg/latexusersgroup/-/z2tNOIF2CVwJ.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.

AdCs

unread,
May 28, 2012, 9:44:02 PM5/28/12
to latexus...@googlegroups.com
Hi,

the structure is like this:
  • Base dir: Main tex file. It includes the other tex files.
    • reports: Various tex files. Among them, there is the one that includes the source code in src directory with my new command, \codigo.
    • src: Source code files.
I run pdflatex against the main tex file in the base dir.
Reply all
Reply to author
Forward
0 new messages