[Tex/LaTex] How to create a book with separately produced chapters

book-design

I want to create a book type file, where each chapter is separatly compiled. That is I get the whole thing as well as each individual chapters in pdf or dvi or ps format. How do I do that?

Best Answer

Without using packages, you could use simply the \input commands:

Write each chapter in a separate file (don't compile these files):

In chapter1.tex:

intro to chapter 1
\section{section 1}
section 1 of chapter 1
\section{section 2}
section 2 of chapter 1

In chapter2.tex:

intro to chapter 2
\section{section 1}
section 1 of chapter 2
\section{section 2}
section 2 of chapter 2

Then write your book as:

in book.tex:

\documentclass{book}

\begin{document}

\title{Title}
\maketitle

\tableofcontents

\chapter{Chapter 1 title}
\input{chapter1}

\chapter{Chapter 2 title}
\input{chapter2}

\end{document}

Compile this file to get your full book.

To get the separate chapter as articles, you can compile the following file:

In chapter1Article.tex:

\documentclass{article}

\begin{document}

\title{Title of chapter X}
\maketitle

\input{chapterX}

\end{document}

If you want them as a book with only one chapter, use the following file. To get the right chapter number, use \setcounter.

In chapter1Book.tex:

\documentclass{book}

\begin{document}

\setcounter{chapter}{X-1}

\chapter{title of chapter X}
\input{chapterX}

\end{document}

etc...

Related Question