[Tex/LaTex] Automatically create two PDF output files from one tex file


Possible Duplicate:
Can one TeX file output to multiple PDF files?

Let's say I have a tex file foo.tex. Now, I want to achieve that pdflatex does not only create a file foo.pdf but simultaneously a file fooxy.pdf which is identical (!) to foo.pdf. Is there a simple solution to this problem?


  • Yes, I could just do this by copying and renaming the file in the file manager. But I want to have an automatic solution.
  • No, I am not crazy. Please don't ask me why I want to do this.

Best Answer

I can think of three ways to approach this:


You could just add a copy command after pdflatex as in the following:

pdflatex foo.tex && cp foo.pdf fooxy.pdf

The does everything you want in one line and it is a simple solution.


You could make it slightly more sophisticated by making a Makefile such as the following:

namebase = foo
nameaddon = xy
tex = pdflatex          # Might wanna set this to latexmk

.PHONY : all
all : $(namebase)$(nameaddon).pdf

$(namebase)$(nameaddon).pdf : $(namebase).pdf
    cp $< $@

$(namebase).pdf : $(namebase).tex
    $(tex) $<

This gives you more flexibility when it comes to naming file and it does not compile or copy unless it is needed. You only have to issue

make all

and make decides what needs to be done.


This does not work but was the first approach I came to think about. The command tee reads from standard input and writes to standard output and the files given as arguments. If pdflatex would write the pdf to standard output you could have used

pdflatex foo.tex | tee foo.pdf fooxy.pdf > /dev/null

but as pdflatex does not this approach fails.