When I include a file from a subdirectory with \include{subdir/sub}
and compile the file with pdflatex -output-directory .tex_test/ main.tex
, pdflatex
complains, that it can't write to .tex_test/subdir/sub.aux
. (Same happens with xelatex
)
Is there a way to automatically create the necessary file structure in the output-directory
? Of course it would also be ok, if sub.aux
would be written directly to .tex_test/
, but I guess that is not possible…
Full MWE:
./main.tex
contains:
\documentclass{article}
\begin{document}
Main Document
\include{subdir/sub}
\end{document}
and ./subdir/sub.tex
contains just anything. More importantly the directory .tex_test/
exists.
Best Answer
Just recreate in the invisible directory the same tree as your "visible" one: I tried and creating a
subdir
directory inside.tex_test
worked.Actually I changed the names, but it's just the same. Here's the log
As you see, the
sub.aux
file is read in from.canasub/canasub
With shell escape enabled, you can create the directory:
Here I assume a Unix system (I don't know how to create a directory on Windows) and that all
\include
commands have the same structureIt should be quite easy to cope with different patterns. Of course you have to add
-shell-escape
to the call ofpdflatex
.However the
.tex_test
part must be hard encoded, as TeX has no internal knowledge of the output directory.