[Tex/LaTex] modular chapters of a dissertation

chaptersincludeinputstandalonesubfiles

I have several different chapters I would like to include into a dissertation. Each chapter is a standalone paper and has its own directory structure (figures, tables, etc.). I would like to retain the ability to compile (and work) each chapter separately but include all of them into the dissertation. What is the correct way of doing this? Using \input screws up the directory structure in addition to the fact that I need to ignore the preamble and abstract of each individual paper.

Best Answer

Use the import package.

Suppose I write a document describing how to make a banana milkshake. Separate the document into the header and the content:

/banana/bananaMilkshake.tex (pseudocode)

\documentclass{whatever}
\begin{document}
\input{bananaMilkshake-content.tex}
\end{document}

/banana/bananaMilkshake-content.tex

Whatever content you want.

Then, in your thesis, just \import* the content sections as needed:

/my_thesis_directory/thesis.tex

...
\usepackage{import}
\chapter{Milkshakes}
\import*{/banana/}{bananaMilkshake-content}

The nice thing about \import* is that you give a path to the file you want to use. Any \input commands or graphics inclusions in the imported files still work. You can also use \subimport if you want relative paths. The asterisk is there to prevent TeX from using files in the local directory which might have the same name as the thing you want to import. See the documentation linked above.

Cutting the document into header and content sections isn't really an "extra" step because you really should do this anyway. For example, I have my package imports and things like that in a common .tex file which is imported as needed (the one package I have to explicitly \usepackage is... the import package). You should have lines like \input{abstract.tex}, etc.

Now, if you want to do something like add external files as appendices with references to one another, it's trickier. See my recent post (complete with working example) about this.