So I'm writing a large document (almost a book) of notes, so to organize the document I have been using subfiles. Most of the time I am unable to compile the section that I am working on, and have to compile the entire document rather than the subsection that I am working on.
Below is how my file is organized: (I have put the name in quotes)
My folders are like so...
FOLDER: "Main"
FILE: "ChapterA.tex"
FILE: "ChapterB.tex"
FILE: "ChapterC.tex"
FOLDER: "Sections"
FOLDER: "TopicA"
FILE: "SubsectionA1.tex"
FILE: "SubsectionA2.tex"
FILE: "SubsectionA3.tex"
FOLDER: "TopicB"
FILE: "SubsectionB1.tex"
FILE: "SubsectionB2.tex"
FILE: "SubsectionB3.tex"
FOLDER: "TopicC"
FILE: "SubsectionC1.tex"
FILE: "SubsectionC2.tex"
FILE: "SubsectionC3.tex"
FILE: "Main.tex"
FILE: "Preamble.sty"
FILE: "style.ist"
File "Preamble.sty" looks like...
\ProvidesPackage{Preamble}
\usepackage{--} %multiple packages for symbols and colors
\usepackage{morewrites}
\geometry{letterpaper,portrait, margin=1in}
[general formatting content for title and table of contents]
[creating some shortcuts and new commands that's used throughout the document using \DeclareMathOperator \newcommand and \catcode]
File "Main.tex" looks like this...
\documentclass{article}
\usepackage{Preamble}
\usepackage{subfiles}
\makeindex[name=aa, title={TITLE},columns=1, intoc, options= -s style.ist]
\begin{document}
\subfile{Main/ChapterA} \NewPage
\subfile{Main/ChapterB} \NewPage
\subfile{Main/ChapterC} \NewPage
\printindex[aa]
\end{document}
File ChapterA, ChapterB, ChapterC looks like this:
\documentclass[../Main.tex]{subfiles}
\begin{document}
\Section{Chapter A}
\subfile{Sections/TopicA/SubsectionA1}
\subfile{Sections/TopicA/SubsectionA2}
\subfile{Sections/TopicA/SubsectionA3}
\end{document}
The Subsection files all are in some similar format like this...
\documentclass[../Main.tex]{subfiles}
\begin{document}
\subsubsection{topic}
\begin{itemize}
\item TEXT...
\end{itemize}
\subsubsection{topic}
Some basic description
\begin{itemize}
\item MORE INFO
\end{itemize}
\end{document}
When I am in "ChapterA.tex" and compile the file, the entire chapter compiles without the stuff from before or after. with only an a yellow error( "Package auxhook Warning: Cannot patch \document, using \AtBeginDocument instead.")
However when I am in "SubsectionA1.tex" and compile the subsection doesn't compile and I get a major error (' /usr/local/texlive/2017/texmf-dist/tex/latex/subfiles/subfiles.cls, line 40 LaTeX Error: File `../Main.tex' not found. ')
I have tried to edit the \documentclass[..] but am unable to get the subsections to compile like the way the chapters are able to. Why does one work and not the other?
\documentclass[../../Main.tex]{subfiles}
(note the second../
), since relative to the subsection files, the Main file with the preamble is two levels above.\subfile
commands inMain
files should use the path../Sections/TopicA/SubsectionA1.tex
etc (note the initial../
).