I have multiple different LaTeX files each which draw their bibliography from the same .bib
file. When they compile I want them to share one bibliography file that is a separate PDF file. For example assume I have
one.tex
two.tex
three.tex
bibliography.bib
I want to create
one.pdf
two.pdf
three.pdf
bibliography.pdf
Where neither one.pdf
, two.pdf
nor three.pdf
have their own bibliography in them, but instead all reference the same bibliography.pdf
file. Is this possible to do, and if so how?
Best Answer
Write a
bibliography.tex
file containingand compile it (LaTeX, BibTeX, LaTeX, LaTeX). Then
one.tex
and the others can beNote that the xcite package was born from a question here on TeX.SX: Use bibliography numbers and citation from other file
Instead of saying
\nocite{*}
inbibliography.tex
you can gather the requested citations from your files by a simple shell one-linerand say
\input{cites}
inbibliography.tex
instead of\nocite{*}
.A bit of explanation
When LaTeX finds a
\cite
command, it writes it in the.aux
file for possible later processing with BibTeX. So\cite{xyz}
will produce a line in the.aux
file of the formIn the presented case you have a big
.bib
file and want that only actually cited entries are extracted from it. But the entries are scattered among three files to be compiled independently and possibly not each of them will cite all the requested entries.So the strategy is to delay bibliography typesetting until all the citations are present in the three
.aux
files. They will show the typical ?? in the text, but this is unimportant.The
bibliography.tex
file will be of the formand we will populate a
cites.tex
file with the necessary BibTeX keys. The one-linerwill find all
\citation{...}
lines in the three.aux
files; they will be filtered bysed
that will change\citation
into\nocite
and the output will be written incites.tex
that will consist of lines of the formwith all the cited entry keys. Now we can run LaTeX on
bibliography.tex
, then BibTeX and then LaTeX again. This will produce the correctbibliography.aux
file that LaTeX will read (via the xcite package) when typesettingone.tex
,two.tex
andthree.tex
again.