[Tex/LaTex] build folder usage issues

includetexmaker

I'm writing my manuscript using TeXlive and Texmaker. I have different folders for chapters, images and frontmatter (including title, declaration, acknowledgements, …) to organize a little bit the writing process. All these documents are properly written.

To be a little bit organized, I would like to use the option in Texmaker of creating a "build" folder for the generated files during compilation (.aux, .nlo, .log, .bbl, …) but I can't use the \include command with that "build" option because I got this error:

! I can't write on file `frontmatter/title.aux'.
\@include ...\immediate \openout \@partaux #1.aux
\immediate \write \@partau...
l.63 \include{frontmatter/title}

If I don't use that option everything works as it should but my main folder is filled with those auxiliary files.
Apparently there is a problem writing the auxiliary files, but I can't figure out why.

On the other hand, if I use \input command, everything works well even with the "build" option selected in Texmaker.

But there is a big difference in using \input instead of \include in a large document as you well know in terms of compilation time and other issues related with numbering and referencing if I want to compile only one chapter.

Here is my MWE:
Main.tex

\documentclass[12pt,a4paper]{report}
\begin{document}
\include{frontmatter/dedication}   %%% Not working with "build" option
%\input{frontmatter/dedication}   %%% It works with "build" option
\end{document}

dedication.tex(included in frontmatter folder which is in the same folder as main.tex)

\chapter*{Declaration}
I declare that ........................

Any hint will be appreciated! Happy new year!

Best Answer

If I'm not mistaken, \input only copy/paste the content in the file, while \include compile the dedicated file and the temp files, amongst which the aux doesn't need to be regenerated if nothing in that part has changed.

However, The error message tells you it is not able to create the folder. See also this topic: latexmk -outdir with \include

So, create your build directory and copy the folder structure of your working directory into that build directory (just the folders).

Happy new year too!

Related Question