6

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.

8

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.

  • great solution! how do you deal with bibliographies in this case? – Alex Aug 31 '14 at 23:54
  • 1
    @Alex: You should probably ask another question, but basically I just have a massive bibliography file in one location and I use that for everything. You can put relative paths in \bibliography{...} commands, and you can put more than one file (comma separated). – DanielSank Aug 31 '14 at 23:58
  • 1
    @Alex: The place things get weird is if you include pre-existing documents as appendices which need to reference each other. See the link in my answer. – DanielSank Sep 1 '14 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.