Making multiple PDFs from 1 TEX file in LaTeX?

I'd like to create multiple documents (output as PDFs after running pdflatex) whose source is from one file. Example:

\documentclass \begin This text will appear in the first PDF. \end \begin This text will appear in the second PDF. \end
  1. I could keep everything in 1 file, with a single, consistent preamble.
  2. I could use ifthen or other loops to automatically generate various alternative forms of a document.
asked Jul 8, 2011 at 7:40 24k 50 50 gold badges 126 126 silver badges 166 166 bronze badges

2 Answers 2

AFAIK this is not possible without some preprocessing of your file, i.e. using a scripting language to produce two separate documents then compiling them separately. Even then I don't think it's a good idea.

The first reason you think this would be useful is handled by putting your preamble in a separate document that is included in as many documents as you want using \include . The second aspect can be handled by using Makefiles and putting the conditional branching to build particular versions of a document in there.

answered Jul 8, 2011 at 8:55 1,917 2 2 gold badges 16 16 silver badges 31 31 bronze badges

I wrote a really simple preprocessor for LaTeX that embeds Ruby code directly into .tex files for this purpose and use the ERB template engine. Here's the source code on Google Code, if you want to take a look. There's not much to it, though I regularly use it from a Ant / latexmk -based build script and it has proved very useful for generating multiple version of my résumé. It works equally well on Linux/Mac OS X/Windows, assuming you have a working LaTex and Ruby installation.

answered Jul 9, 2011 at 23:17 Richard Cook Richard Cook 33k 5 5 gold badges 48 48 silver badges 72 72 bronze badges

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.4.14806