Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

pdflatex: output multiple PDF files

102 views
Skip to first unread message

mgoossens

unread,
Mar 6, 2009, 7:03:36 AM3/6/09
to
I am running pdflatex and would like to separate the output into
several distint PDF files (e.g. every chapter in its own file). How do
I open and close the output stream and specify the name of each PDF
file? thanks. mg

Lars Madsen

unread,
Mar 6, 2009, 7:30:36 AM3/6/09
to

isn't it easier to post process?


Not sure if pdftex can change output stream on the fly

--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

Bob Tennent

unread,
Mar 6, 2009, 7:38:20 AM3/6/09
to

Either use \includeonly and run pdflatex multiple times, or create
separate "top" files and run pdflatex on each, or run pdflatex once
and break up the PDF using a program like pdftk:

http://www.accesspdf.com/pdftk/

There are also other possibilities involving first converting the PDF to
Postscript.

Bob T.

Marius Gurak

unread,
Mar 6, 2009, 8:24:32 AM3/6/09
to
On that note, is it possible to somehow have pdflatex place markers in
the PDF file, which can then be used by a post processor?

For example, if I want to split the PDF into separate PDFs for every
chapter (assuming every chapter starts on a new page), and if I know on
which page each chapter starts, then I can easily do this using e.g.
ghostscript.

In general, however, the page on which a particular chapter starts my
change as the source changes. Could I define the \chapter command such
that it places a PDF \special in the final file, marking the position
where gs will split the file?

Marius

Heiko Oberdiek

unread,
Mar 6, 2009, 8:57:20 AM3/6/09
to
Marius Gurak <anon...@chaschperli.xyx> wrote:

> For example, if I want to split the PDF into separate PDFs for every
> chapter (assuming every chapter starts on a new page), and if I know on
> which page each chapter starts, then I can easily do this using e.g.
> ghostscript.

You can use \include and \includeonly.
Or write the page number at each chapter start into an auxiliary file.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Heiko Oberdiek

unread,
Mar 6, 2009, 8:57:21 AM3/6/09
to
Lars Madsen <dal...@RTFSIGNATUREimf.au.dk> wrote:

> Not sure if pdftex can change output stream on the fly

No, pdfTeX generates just one output PDF file.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

T3X

unread,
Mar 6, 2009, 9:20:04 AM3/6/09
to
On Mar 6, 1:24 pm, Marius Gurak <anonym...@chaschperli.xyx> wrote:
> In general, however, the page on which a particular chapter starts my
> change as the source changes. Could I define the \chapter command such
> that it places a PDF \special in the final file, marking the position
> where gs will split the file?

It should be much simpler to write those page numbers to a file and
use that in postprocessing. You could even write the entire
postprocessing script from TeX and just call it after compilation.

Cheers,

Tomek

Ulrich D i e z

unread,
Mar 6, 2009, 10:40:48 AM3/6/09
to
mgoossens wrote:

If \write18-feature is enabled for your TeX-distribution, you
can use it in order to launch other TeX-runs from within TeX.
With each of these "other" TeX-runs, you can specify another
value for the jobname-option and thus produce different
pdf-files with different content.

The example below is tested under MiKTeX 2.4.

Ulrich

\documentclass{article}

\ifx\conditionmacro\undefined
\immediate\write18{%
pdfLaTeX --jobname="\jobname1"
\gdef\string\conditionmacro{1}\string\input\space\jobname
}%
\immediate\write18{%
pdfLaTeX --jobname="\jobname2"
\gdef\string\conditionmacro{2}\string\input\space\jobname
}%
\immediate\write18{%
pdfLaTeX --jobname="\jobname3"
\gdef\string\conditionmacro{3}\string\input\space\jobname
}%
\expandafter\stop
\fi

\begin{document}
\ifnum\conditionmacro=1 Condition is 1\fi
\ifnum\conditionmacro=2 Condition is 2\fi
\ifnum\conditionmacro=3 Condition is 3\fi

\verb|\conditionmacro| is \texttt{\meaning\conditionmacro}.
\end{document}

0 new messages