3

I'm trying to combine four separate .tex documents into one big "book" with each document as a chapter. I use the import package.

This is essentially what my main document looks like:

\documentclass{paper}
\usepackage{import}

\begin{document}

\section{Chapter 1}
\import{Chapters/}{Chapter1}


\section{Chapter 2}
\import{Chapters/}{Chapter2}


\section{Chapter 3}
\import{Chapters/}{Chapter3}


\section{Chapter 4}
\import{Chapters/}{Chapter4}

\end{document}

When I do it this way, I have to remove all options and preambles of the individual imported files, which means I can't typeset them on their own.

Chapter 1 just contains text, no preamble or options:

This is chapter one, with all its glorious information.

What I'd like:

\documentclass{paper}
\usepackage{xcolor, graphicx}

\graphicspath{{tex/img/}}

\setlenght\parindent{0pt}

\title{Chapter 1}

\begin{document}
\maketitle

This is chapter one, with all its glorious information.

\end{document}

I want to be able to look into every document, typeset them and use them individually, but also in combination within the main document. Is it possible to include/input/import .tex-documents without removing all of the preamble of said documents? Or is there another way to do all of this?

Anderson
  • 2,333
  • 4
  • 17
  • 19
Rikardny
  • 225
  • You may want to look into the use of \includeonly to make the individual chapters. – cslstr Jul 14 '14 at 11:21
  • 2
    I tend to use the docmute package. It redefines \input and thus \include such that anything outside the document env is ignored. I've made proceedings like this. You just have to make sure that the packages needed by the various contributions are also in the master. – daleif Jul 14 '14 at 11:22
  • The combine package may help: http://tug.ctan.org/tex-archive/macros/latex/contrib/combine/combine.pdf – Ethan Bolker Jul 14 '14 at 12:05
  • @daleif That was just the kind of thing I was looking for, thanks! :) – Rikardny Jul 14 '14 at 12:14

0 Answers0