Normally, LaTeX will only create references for the BibTeX entries cited in the text. Is there a way of extracting these entries into a different .bib file automatically? For example if I have a .bib file with two entries, and only one is cited in a particular text, I need a way of creating a new .bib file with just that reference.
253k 70 70 gold badges 730 730 silver badges 796 796 bronze badges asked Jan 21, 2012 at 12:50 user1032285 user1032285 For Mac users of BibDesk, there is BBL to BIB with BibDesk. Commented Sep 19, 2013 at 3:08For Windows, JabRef provides this capacity: see [here][1] [1]: tex.stackexchange.com/questions/98370/…
Commented Jul 18, 2014 at 14:10 might be a duplicate of tex.stackexchange.com/questions/417/… Commented Feb 23, 2015 at 0:09 BBL to BIB seems cool but does not seem to be compatible with biber/biblatex. Commented Nov 29, 2018 at 9:18@canIchangethis: did you add one of the other answers below to the contents of export.sh ? If so, the generated file should appear in the other outputs within the log pane of overleaf.
Commented Dec 20, 2023 at 17:13With a TeX Live distribution (possibly also with MiKTeX) there is a bibexport program. Assuming your document is myarticle.tex , you have to compile it normally and then you call
bibexport -o extracted.bib myarticle.aux
where extracted.bib is the name that you want to give to your new .bib file. Notice that you have to give the extension .aux (or no extension at all).
Then you have to change the name of the .bib file in your document, in order to use extracted.bib .
answered Jan 21, 2012 at 15:05 1.2m 141 141 gold badges 2.7k 2.7k silver badges 4.3k 4.3k bronze badges In MiKTeX 2.9 this tool is missing :-( Commented Feb 15, 2013 at 16:24Although this falls outside of the scope of the question, perhaps a brief word about how this tool does not work with biber -driven bibliographies (or with .bib files that use biblatex fields such as date instead of year ) is in order.
Commented Feb 15, 2013 at 16:29@jon bibexport uses BibTeX for doing its job. The manual tells how to add new fields (section 1.4). For biblatex /Biber compatibility the script should look not only for \citation commands in the aux file but also for \abx@aux@cite .
Commented Feb 15, 2013 at 16:42@egreg -- Right. I was thinking more for people who look at your answer, but don't realize why bibexport isn't working for them; most of them are not going to be modifying bibexport.sh . Another problem that might arise is if you use non-standard entry types (from BibTeX's perspective). I use @Collectio<. , e.g., for essay collections; that comes through as @<. .
Commented Feb 15, 2013 at 20:02+1 for the usage example – the bibexport help page doesn't mention that the main argument is the .aux file (it might be obvious, but wasn't for me).
Commented Feb 23, 2015 at 0:05jabref can do this in both command line and gui modes.
Keep your master.bib file open in jabref. Then in Tools → New subdatase based on AUX file to get
Here select the .aux file, click parse , and select and the generate . You should get a sub database opened in jabref. Save it.
From command line, assuming that you take care of paths do this:
jabref.jar -a filename[.aux],newBibFile[.bib]
5 2 2 bronze badges
answered Nov 14, 2014 at 2:11
user11232 user11232
In contrast to the bibexport -solution above, this one works when working with biblatex and biber .
Commented Jan 16, 2018 at 10:30
This is a supplement to pavel's answer which aims to address an issue raised in the comments. It is therefore a more specific solution than the one there: the simpler command will work fine if you don't need to resolve crossref fields in .bib entries.
In order to resolve crossref fields in a .bib file when using biblatex / biber , you need to tell biber what to do.
pdflatex .tex biber --output_format=bibtex --output_resolve .bcf
Where latex , xelatex , lualatex etc. can be substituted for pdflatex as appropriate. So long as it generates your .bcf it is fine.
answered Nov 14, 2014 at 2:16 211k 13 13 gold badges 285 285 silver badges 560 560 bronze badgesWith biblatex / biber you can use
biber document-base-name.bcf --output_format=bibtex
To resolve crossref fields, add the option --output-resolve-crossrefs .
answered Apr 14, 2014 at 12:55 861 8 8 silver badges 14 14 bronze badges The above command doesn't work with entries using the crossref field. Commented Apr 18, 2014 at 14:32 @asr See my answer below. You just need to tell biber to do this. Commented Nov 14, 2014 at 2:29In addition to egreg's answer, I'd like to point out an alternative solution. Nelson Beebe has developed utilities called bibextract , citetags and citefind to handle sub-bibliography databases. You can obtain them here.
In this case, you would compile the document normally and then type in a shell
citetags myarticle.aux > myarticle-tags citefind myarticle-tags mybib.bib > mysubbib.bib
The first command prints all the citation keys used in your .tex , while the second selects all the entries from my bib.bib with keys from myarticle-tags . Of course, one can easily write a script to merge the two commands if needed.
Although it works in a similar fashion as bibexport , this solution has the advantage that it does not delete the biblatex fields such as date , while bibexport does by default as mentioned in the comments. It also works with biblatex if you use bibtex as a backend, but as far as I know, it does not if you use biber .