GeneralSplit Output to separate Files for each Chapter

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
oktoberjazz
Posts: 1
Joined: Mon Aug 13, 2012 11:56 am

Split Output to separate Files for each Chapter

Post by oktoberjazz »

Hello,

I can't find a solution to this problem on the internet. Starting from an input file in the »book« class, do you know a smart way to compile it and produce not a single PDF, but many files, one for every chapter? I mean something like this:

http://cacr.uwaterloo.ca/hac/

So that is possible to share only single chapters and not only the whole document

Thank you for your help

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10328
Joined: Mon Mar 10, 2008 9:44 pm

Split Output to separate Files for each Chapter

Post by Stefan Kottwitz »

Hi,

welcome to the board!

If each chapter is a file (chapter1.tex, ...), which you read in by include, you could use \includeonly to include just the first chapter, i.e.

Code: Select all

\includeonly{chapter1}
and compile, which produces a pdf with just the first chapter, but correct references.

Then you repeat it with chapter 2. Well, that's some work. It's more intended for easier development of larger documents, so you don't need to compile the whole book each time although you work on just one chapter.

Of course one could write a script, or even a LaTeX document which calls LaTeX itself several times producing chapter files. Also bit of work to program it.

The easiest way, however, is to use an external tool for splitting the big pdf, such as pdfsam or pdftk, or use pdfpages with LaTeX.

Stefan
LaTeX.org admin
Post Reply