I am writing a long document with two other people using Dropbox as the file storage mechanism. I want to have each person be able to work on their piece individually. Therefore I want to be able to compile each document seperately, as well as compile the main document. The subfiles package seemed perfect for this.
I tried following the example for modular documents on Wikibooks, but it is not working for me. The top level document will build, but the lower level ones will have file not found errors.
Here is my setup:
- Images folder
- tex folder
- main.tex
- styles.sty
Inside main.tex:
\documentclass[11pt,letterpaper]{article}
\usepackage{styling} %includes \usepackage{subfiles}
\begin{document}
\maketitle
\tableofcontents
\subfile{./tex/subpiece1}
\end{document}
Inside subpiece1 in tex folder:
\documentclass[../main.tex]{subfiles}
\graphicspath{ {Images/subpiece1/} }
\begin{document}
\section{sectiontitle}
%Images and text
\end{document}
The error when building the subfile seperately:
../main.tex:4: LaTeX Error: File `styling.sty' not found. [^^M]
Best Answer
I came accross the same problem you did when i compiled my first multi-file document using the subfiles package.
Since I am not a long term latex user i do not fully understand the mechanics of the problem but I suspect the problem is that when you compile the "slave" file (in your case 'subpiece1.tex') your compiler searches for the custom package in the same directory as 'subpiece1.tex' and the other default tex directories.
I managed to solve the problem by changing the \usepackage{} command to also include a relative path that will be common for both the "master" and the "slave" .tex files.
What you need to do:
main.tex now reads
subpiece1 now reads
I personally prefer to group my preamble.sty into the same folder as my main.tex but the basic idea is the same. I believe any path would be fine as long as the relative paths are the same for both the 'main.tex' and 'subpiece1.tex' files.
I also suspect there are better/more elegant ways of getting around this problem but this worked for me so far.