7

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.)

2
  • A first idea, not sure if exactly what you want. Based on the first document, you can extract a bib file only with your cited entries (see tex.stackexchange.com/q/41821/105447). Then on the second one, a \nocite{*} plus \printbibliography would do. True, every time the first document is changed, the extraction step would have to be repeated. – gusbrs Apr 17 '18 at 10:09
  • 1
    I'd just go for adding an extra page at the end where you re-print the bibliography, setting the page counter as required, then post-process using a PDF extraction tool. Probably not the solution you want ... – Joseph Wright Apr 17 '18 at 10:53
7

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 docmain.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 docmain (it lives in docmain.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@info@noline{... file '#1.bbl' not found}%
       \typeout{No file #1.bbl.}}%
    \blx@bblend
    \endgroup
    % global sorting as this is called at BeginDocument
    \csnumgdef{blx@labelnumber@\the\c@refsection}{0}}}

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

\importbibfrom{docmain}

\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.

1
  • Thanks, this solves my problem. My hacky solution so far was to copy and rename the bbl file (from maindoc.bbl to coverletter.bbl in your notation) but your importbibfrom command is certainly more elegant. – fuenfundachtzig Apr 17 '18 at 11:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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