# How do we do hierarchical includes with local paths?

I need to generate an appendix with hundreds of tables. I put several tables on a page, as an earlier question established. The first level consists of pure tables, created as \begin{tabular}...\end{tabular} blocks. Let's call 4 such primitive files ch1-{a,b,c,d}.tex, i.e. ch1-a.tex,ch1-b.tex, ... These four documents are emitted into a directory /tex/ch1/.

The second level, which I call 2x2-ch1-abcd.tex, is also a tabular, containing

\include{a}

-- it is generated in the same subdirectory, /tex/ch1/. So far so good. If I wrap 2x2-ch1-abcd.tex in a preamble, it compiles.

Now I need to assemble such level 2 aggregates into a thesis. I have the master document as /tex/thesis.tex. If I say, in it,

\include{ch1/2x2-ch1-abcd}

-- I get the no nested includes error. If I replace \include by \input, the second level cannot find the first level files anymore.

I'd like to avoid encoding first-level paths into second-level matrices, to keep paths only in the master document. Can it be achieved within LaTeX without external symlinks?

-

I believe (untested) that you can solve the problem with the import package:

\usepackage{import}
...
\subimport{ch1/}{ch1-a.tex}
...
\input{2x2-ch1-abcd}


(where indentation denotes inclusion within the file above in the heirarchy). If you wish to \include the chapter file (rather than \input) it, use \subincludefrom instead of \subimport.

-
Thanks Will -- I decided to simply generate proper paths for each \input, but this is a very interesting path and yielded many more things on hierarchy, such as TEXINPUTS, security policy, etc. –  Alexy Feb 4 '11 at 8:21