How do I create a book with separately produced chapters?

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?

1.2m 141 141 gold badges 2.7k 2.7k silver badges 4.3k 4.3k bronze badges asked Jul 18, 2012 at 7:01 Manjil P. Saikia Manjil P. Saikia 261 2 2 gold badges 3 3 silver badges 4 4 bronze badges

Compiling each chapter separately will produce a PDF file with the same "Chapter 1" heading, are you ok with this?

Commented Jul 18, 2012 at 7:41

Welcome to TeX.SE. I would suggest you have a look at the the standalone package. There are numerous examples on this site.

Commented Jul 18, 2012 at 7:49 Probably the quickest method is to separate the chapters with a PDF utility such as qpdf or pdftk Commented Jul 18, 2012 at 7:50 possible duplicate: tex.stackexchange.com/questions/31334/… Commented Jul 18, 2012 at 9:53

It's not quite clear from your question exactly what you want to achieve with regard to page and chapter numbering. Have you looked at the functionality provided by \include and \includeonly , described, for example, on page 18 of The LaTeX Companion (2nd Edition)?

Commented Jul 18, 2012 at 9:53

2 Answers 2

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

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

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

Then write your book as:

\documentclass \begin \title \maketitle \tableofcontents \chapter \input \chapter \input \end

Compile this file to get your full book.

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

\documentclass \begin \title \maketitle \input \end

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

\documentclass \begin \setcounter \chapter \input \end
answered Jul 18, 2012 at 9:35 1,130 8 8 silver badges 5 5 bronze badges

One approach would be to have each chapter in a separate file and then use the \include command to fold them all into a big main file. Then you can use \includeonly to compile each chapter individually. If you compile the whole thing first, then when you do \includeonly you'll get the right numbering and crossreferences would work.

To automate things, what you'd want is a script that does \includeonly for each chapter one after the other, and also changes the jobname such that each chapter is compiled to a distinct file.

answered Jul 18, 2012 at 9:54 74k 56 56 gold badges 260 260 silver badges 369 369 bronze badges

You must log in to answer this question.

Linked

Related

Hot Network Questions

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.9.11.15092