# using \include while having output files in separate directory in big project

At this moment my project looks like this

The build folder contains the main.tex file that looks like this

\input{../latex/preamble}
\begin{document}
\input{../latex/chapter1}
\input{../latex/chapter2}
\end{document}


all figures are contained in /src and the references.bib file sits in /ref.

What I would like to do, is to use \include instead of \input (except for the preamble) in my main file while keeping this document structure or putting the main.tex file in the root folder while keeping the output in /build. I have tried to do this by putting my main.tex file in the root folder (and changing the relative paths for include) and running pdflatex --output-director=./build main.tex

If possible I would also like to have the .aux files for all my chapters in some separate directory (or in /build) to keep everything clean.

I have been messing around with this for a few hours now and I can't get it right. It is the combination of include and the output files in build that seems to cause the problem. I get the message

 ! I can't write on file ./latex/test.aux'.
\@include ...\immediate \openout \@partaux #1.aux
\immediate \write \@partaul.4 \include{./latex/test}


Any advice on this?

Additional question: In this setup, where should I place biber.conf ?

• Why would you want to change \input for \include if it already works with \input ? – Nicolas Nov 6 '15 at 15:56
• @Nicolas presumably so you can use the extra features that \include provides, notably \includeonly – David Carlisle Nov 6 '15 at 16:01
• @DavidCarlisle Everything works fine with input, it's with include that it refuses to compile correctly – user138784 Nov 6 '15 at 16:31
• @user138784 Sorry I meant to say you haven't said what fails if you use \include. "refuses to compile correctly" is no information at all, you need to copy the exact error message from the log, preserving linebreaks by putting it in a code {} section in the question. – David Carlisle Nov 6 '15 at 16:37
• @AndrewCashner Thanks! This solved it. Any idea about the biber.conf file? – user138784 Nov 6 '15 at 17:01

## 1 Answer

You have to have the same directory structure in the output directory as in the main tree so that TeX knows where to put the .aux files it writes for the \include command. So if you \include{latex/chapter1} and you output to build/ then you need to create a directory build/latex.