# How do I [simply] typeset a bibliography as a separate PDF?

I'm preparing a document that requires the body of the text and the references to be separate PDF files. Of course, the bibliography comes from \bibliograpy command and the text citations come from \cite command.. you need both to be present in order for BibTeX to work.

I have been typesetting the document and then breaking it apart with pdftk(1) -- but that is annoying and requires me to know page numbering. Is there a TeX-only way to do it?

I'm not sure if this is exactly what you want, but if you have foo.bbl from running BibTeX, then you can make a simple document which typesets just the bibliography.

\documentclass{article}
\begin{document}
\input{foo.bbl}
\end{document}


To have the bibliography not appear in your main document, use the following.

\usepackage{comment}
\excludecomment{thebibliography}


Edit:
This is wrong. (I'd completely forgotten that I'd given this answer.) As is noted in the comments, doing this breaks things. A friend asked me how to do this just the other day and the solution I gave her is better, but I'm not sure that it's the best way.

{\setbox0\vbox{\bibliography{foo}}}


This typesets the bibliography in a vertical box and stores it in box register 0. Then the group ends and box 0 is restored.

• That does get me halfway there-- but I'm still left with the references in the main document as well, since \bibliography is the command that creates the .bbl. So I still need to use pdftk to get rid of them there. Sep 21, 2010 at 0:04
• @Brandon Kuczenski: Hopefully that edit addresses the second part.
– TH.
Sep 21, 2010 at 0:09
• That works- I just have to comment out \excludecomment the first time through (builds full doc with references), then build the bibliography with the existing .bbl, then finally uncomment \excludecomment (haha) to build the full doc without references. Still requires interaction, but easier than pdftk. Sep 21, 2010 at 0:34
• @Brandon Kuczenski: It shouldn't require you to do that. I just tried it again and the first build produced the .aux, running bibtex produced the .bbl, exactly as I'd expect. Can you post an example of where that is failing?
– TH.
Sep 21, 2010 at 1:55
• I do get the aux and bbl, but my author-date cites were not being populated. The problem may be in my work-flow. I'll take a closer look and report back if I can't get it working. Sep 21, 2010 at 21:01

I actually like the other solution better (and have so voted), but if you wanted to stick with pdftk, one option would be to use synctex to determine on what page the bibliography started, set that to a variable which is then passed to pdftk.

On linux or unix (probably) mac, e.g., you might use a script like this:

#!/bin/bash

# first, process the file
pdflatex -interaction=nonstopmode -synctex=1 myfile.tex
bibtex myfile
pdflatex -interaction=nonstopmode -synctex=1 myfile.tex
pdflatex -interaction=nonstopmode -synctex=1 myfile.tex
# now check where the bibliography starts
bibpage=$(synctex view -i 1:1:"myfile.bbl" -o "myfile.pdf" | grep -m1 'Page:' | sed 's/Page://') # now call pdftk to break it apart pdftk A=myfile.pdf cat A1-$((endpage - 1)) output myfile-body.pdf
pdftk A=myfile.pdf cat A\${bibpage}-end output myfile-bibliography.pdf


or something of that nature.

• Nice. I was aware of pdftk, but I've never looked into it before.
– TH.
Dec 20, 2010 at 12:52