2

Sorry if this is a dupe. Searching for 'extract bibtex' or 'export bibtex' just gives me results about getting bibtex from other formats, like zotero.


I have a single, huge biblatex file, where I keep all of my bibliographic information. I keep all of my tex work (essays, papers, collated notes etc.) under version control and push most of it to a personal git forge. Part of the reason I like this is that my research and writing processes are transparent ('open source writing' I suppose?), and if they wanted to, anybody could download the sources and compile my paper in a bigger font, or just extract a single chapter, or whatever. This programatically generated edition of the TLP is a great example of this sort of thing.

For this to work properly, all the data necessary to compile the file needs to be present in the repo. Obviously the text and formatting are there, but since I have a monolithic, locally stored bib file, the reference data for resolving citations is not. I could just copy/hardlink the file into the repo, but this would introduce a big file with lots of unneccessary data. In the case of hardlinking (preferable for this sort of thing) adding something new would make it look as if there were changes in the repo, even when the new entry wasn't relevant to (cited in) the paper that repo contained.

So what I want is to be able to dump all the data of every citation in a given .tex file into a file. I can then just add a commented line and explanation in the preamble that this file contains all the data. Presumably this will be part of the compilation chain -- part of latexmk, or some bibtex processing in the preamble? Obviously, I'd also like to make sure that the resulting file is as similar as possible between runs, with new references being the only difference, so it should probably be sorted somehow.

I can't be the first person to think about this sort of thing, so I'm sure there must be a great solution out there somewhere. Thanks in advance.

1 Answers1

5

You can use biber to extract citations. E.g. with the following main.tex

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\begin{document} \cite{doody}

\end{document}

Then after

 pdflatex main
 biber --output-format=bibtex main

you will get a main_biber.bib with this content:

@ARTICLE{doody,
  AUTHOR = {Doody, Terrence},
  ANNOTATION = {An \texttt{article} entry cited as an excerpt from a \texttt{collection} entry. Note the format of the \texttt{related} and \texttt{relatedstring} fields},
  DATE = {1974},
  JOURNALTITLE = {The Journal of Narrative Technique},
  LANGID = {english},
  LANGIDOPTS = {variant=american},
  NUMBER = {3},
  PAGES = {212--225},
  RELATED = {1e63d4bbc14872275675171be2dfa906},
  RELATEDSTRING = {\autocap{e}xcerpt in},
  TITLE = {Hemingway's Style and {Jake's} Narration},
  VOLUME = {4},
}

@COLLECTION{1e63d4bbc14872275675171be2dfa906, OPTIONS = {uniquename=false,skiplab=1,uniquelist=false,skipbiblist=1,skipbib=1}, EDITOR = {Matuz, Roger}, LOCATION = {Detroit}, PUBLISHER = {Gale}, ANNOTATION = {A \texttt{collection} entry providing the excerpt information for the \texttt{doody} entry. Note the format of the \texttt{pages} field}, DATE = {1990}, LANGID = {english}, LANGIDOPTS = {variant=american}, PAGES = {204--208}, TITLE = {Contemporary Literary Criticism}, VOLUME = {61}, }

As you can see it also resolved the related key.

Ulrike Fischer
  • 327,261