10

I have a document with a bibliography that I create using biblatex with the biber backend. I.e., somewhere in this document, there is a line

\printbibliography

which prints the bibliography (say what).

Now I am required to create an additional cover letter which repeats the bibliography. This is a different document (in a different directory if that matters) and I was wondering if there is a way to persuade biblatex to print the bibliography at the end of the cover letter again when I compile it. (That would, of course, require the original document to always be compiled first, but that I would manage.)

Any ideas?

(I could just copy over the pages with bibliography with pdfpages but that's ugly because that would have wrong page numbers and I would always have to adjust the page range, should it change in the original file.)

0

1 Answer 1

9

There is no interface to import the exact bibliography of another document. But in certain situations work-arounds are available.

All the information for citations and the bibliography lives in the .bbl file. That file is written by Biber following requests by biblatex in the .bcf file. So you can try to import the .bbl file of the other document to obtain its bibliography. This works as long as the set-up in both documents is simple: You can't have multiple refsections, the importing document can't cite sources that were not cited in the original document, etc.

Assuming you have a document called maindoc.tex with citations and bibliography that has gone through the complete compilation sequence of LaTeX, Biber , LaTeX, LaTeX you can then import the bibliography from maindoc (it lives in maindoc.bbl so that file must exist) in another document (coverletter.tex) with

\documentclass[american]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}

\makeatletter
\newcommand*{\importbibfrom}[1]{%
  \def\blx@bblfile{%
    \blx@secinit
    \begingroup
    \blx@bblstart
    \InputIfFileExists{#1.bbl}
      {\blx@info@noline{... file '#1.bbl' found}%
       \global\toggletrue{blx@bbldone}%
       \blx@generate@bbl@mdfivesum@found{#1.bbl}}
      {\blx@info@noline{... file '#1.bbl' not found}%
       \typeout{No file #1.bbl.}%
       \blx@generate@bbl@mdfivesum@notfound}%
    \blx@bblend
    \endgroup
    % global sorting as this is called at BeginDocument
    \csnumgdef{blx@labelnumber@\the\c@refsection}{0}}}

\let\blx@rerun@biber\relax
\makeatother

\importbibfrom{maindoc}

\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

You only need to compile the importing document coverletter with LaTeX (at least twice), don't run Biber on that file.

You can cite all entries that are in the bibliography and get the exact same bibliography as maindoc.tex.

Assuming maindoc.tex was

\documentclass[american]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson,vizedom:related}
\printbibliography
\end{document}

the coverletter.tex from above yields

enter image description here

edit: See How to use refsection and xcite together? for guidance on how to use different refsections and for help with defernumbers.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .