How to convert PubMed references to BibTeX
Time and again, you need to write a paper in LaTeX with at lot of citations from PubMed. And we all know that PubMed does not support the BibTex format. Fortunately, you do not have to go through the pain of a manual conversion. If you are familiar with basic scripting, this can be done fairly easily with the following steps.
Write your TeX document with pubmed citation numbers. Each article on pubmed has a pmid which consists of numbers only, which is the key of the PubMed record of this article. For instance, when you cite the PubMed article 22999052 in your TeX document you would write
Extract the pmids from the tex document. For instance, if your TeX document is called
document.tex, at the Linux command line you can do this with
grep -o "pmid[0-9]*" document.tex | sort -u | sed 's/pmid//'
Use the eFetch API to get the PubMed records in XML format. Assuming that you now have a comma-separated list of pmids somewhere ready (in the example below, the pmids are
22999052,21813512), paste the following in your browser text box (or open this link in a new window for an example).
Save the output in a file called
citations.xml for instance. Then use xslt to convert the results to BibTex. First you need to download the file
pubmed2bibtex.xsl from here, and then at the Linux command line you need to run
xsltproc (installed by default on Ubuntu).
xsltproc pubmed2bibtex.xsl citations.xml > citations.bib
comments powered by Disqus