Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 12 down vote accepted

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.

share|improve this answer
    
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. –  Brandon Kuczenski Sep 21 '10 at 0:04
    
@Brandon Kuczenski: Hopefully that edit addresses the second part. –  TH. Sep 21 '10 at 0:09
    
oh ok, I'll give it a try. thanks! –  Brandon Kuczenski Sep 21 '10 at 0:24
    
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. –  Brandon Kuczenski Sep 21 '10 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 '10 at 1:55
show 1 more comment

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.

share|improve this answer
    
Thanks for pointing out synctex: seems useful! –  Brandon Kuczenski Sep 21 '10 at 21:03
    
Nice. I was aware of pdftk, but I've never looked into it before. –  TH. Dec 20 '10 at 12:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.