Say I have a document structured as follows.
main.tex
+ ch1
- ch.tex
- s1.tex
- s2.tex
+ ch2
- ch.tex
- s1.tex
- s2.tex
Here, *.tex are LaTeX files, and ch1 and ch2 are directories.
% main.tex
\documentclass{article}
\usepackage{import}
\includeonly{ch1/ch}
\begin{document}
\subimport{ch1/}{ch}
\subimport{ch2/}{ch}
\end{document}
% ch1/ch.tex
\input{s1}
\input{s2}
% ch1/s1.tex
Section 1.1
% ch1/s2.tex
Section 1.2
% ch2/ch.tex
\input{s1}
\input{s2}
% ch2/s1.tex
Section 2.1
% ch2/s2.tex
Section 2.2
Unfortunately, this compiles the whole document, not just chapter 1. I'm probably doing this completely wrong, but I was trying to do the following. I have a separate folder for each chapter; in each chapter folder, I have a file ch.tex that manages the chapter as a whole, and files s1.tex, s2.tex,... that contain the major sections of the chapter. I am using the import command because I want to be able to use relative paths within ch.tex (both for inputing the section files, and for things like including graphics). However, in order to speed up compilation, I want to be able to use \includeonly. Is there a way to get the advantages of both import and \includeonly? What is the best practice for structuring large documents like this? (I'm curious about the best practice even if it means giving up relative paths or includeonly. Based on the other posts I read, it seems like the experts favor include instead of import [How to use the import package?, Splitting a large document into several files, How to make "\input" in a "\include"-d file use the correct current path? ] -- is there a good reason for this?) I saw a post (Getting \includeonly functionality with import package) that I hoped would give me the answer, but that post ended up skirting the actual issue.
chXare directories I'd simply use\input{chX/sY.tex}to include the sections. Keep it simple! – Dox Jul 08 '13 at 11:12