Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
Sorry, what is the question? –  yo' Aug 31 at 22:38
    
rewrote for clarity –  Alex Aug 31 at 22:46
    
Don't forget to accept an answer if you find one acceptable. –  DanielSank Aug 31 at 23:59
    
just did, thanks! –  Alex Sep 1 at 1:01
    
Do you use some UNIX like system? –  Michael Grünewald Sep 1 at 6:42

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
    
great solution! how do you deal with bibliographies in this case? –  Alex Aug 31 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 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 at 0:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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