[Tex/LaTex] How to make the main file recognize relative paths used in the imported files

includeinputpaths

I'm currently using doxygen to generate some documentation for a project,
and doxygen generate some LaTeX code that then can be used to generate a nice pdf.

But let's say I would like to write another document, and in that document include the doxygen generated LaTeX code as a part of that document.

How would I do that? Has anybody done this type of stuff?


My try is to get the code, generate the LaTeX code without the "header".
So I end up with a dir called code/doc/latex/, seen from the place where I have my own main.tex.

And try in include that LaTeX code from my main.tex with input.

\input{ code/doc/latex/refman.tex }

But when I try to include the code/doc/latex/refman.tex (the doxygen, main.tex),
he complains that he can't find the other LaTeX files that was generated by doxygen.
It seems like he is searching in the same dir as my main.tex and not in code/doc/latex/.

This is more or less how the refman.tex looks like:

\chapter{Todo List}
\label{todo}
\hypertarget{todo}{}
\input{todo}
\chapter{Class Index}
\input{annotated}
\chapter{File Index}
\input{files}
\chapter{Class Documentation}
\include{struct__offsetChannel}
\include{struct__offsetPixel}
\include{struct__tPixel}
...
...

Any ideas would be welcome.

A solution could be to write a script that edits all the generated LaTeX code, and simply adds this path but this seems like a overly complicated solution.


Update:

The error I get is like this one

! LaTeX Error: File `todo.tex' not found.

Update:

If I change all the \input \include and \includegraphics like this it works.

\input{todo} -> \input{code/doc/latex/todo}

But there must be a way to make LaTeX understand that he should look into the code/doc/latex/ for the code?

Best Answer

I'm fuzzy on the details, but the import package should do what you want. Off the top of my head, I think the syntax is

\usepackage{import}
...
\subimport{code/doc/latex/}{refman.tex}

Update: Thanks Willie for pointing out \subimport which seems to be the better command to use here over \import.

The commands \import{full_path}{file} and \subimport{path_extension}{file} set up input through standard LaTeX mechanisms (\input, \include and \includegraphics) to load files relative to the \import-ed directory. There are also \includefrom, \subincludefrom, and * variants of the commands. The author is Donald Arseneau.