EndNote to BibTeX and LaTeX

In the beginning of my PhD, I had a training held by the institute on how to use EndNote. EndNote is quite nice actually, it has some features that other reference management softwares don’t have (also the one I previously used). EndNote is very easy also to use if you are using Microsoft Word. Sadly, I am a LaTeX (or Rmd + Pandoc) user. I have been using LaTeX for around four years now. I feel I won’t be able to move on to any other document preparation system. For people that use LaTeX, using reference management software is a must to generate BibTeX automatically. However, it is not a straight forward process if you are using EndNote. Here, I will share some tips to generate BibTeX from EndNote.

Generating bib file entry from EndNote

There are two easy way to do this. You can select the reference(s) you want to export to BibTeX format and either:

  • right clicked on selected references, and choose “Copy Formatted”, or
  • click “File” > “Export”, and you can specify the file name and directory.

Either way, you must get this bib entry results:

@article{RN160,
   author = {Balke, I. and Zeltins, A.},
   title = {Recent Advances in the Use of Plant Virus-Like Particles as Vaccines},
   journal = {Viruses},
   volume = {12},
   number = {3},
   ISSN = {1999-4915 (Electronic) 1999-4915 (Linking)},
   DOI = {10.3390/v12030270},
   url = {https://www.ncbi.nlm.nih.gov/pubmed/32121192},
   year = {2020},
   type = {Journal Article}
}

Notice here that, using the default style in EndNote, the label appeared will be the record number of related reference(s). Using this record number as a label is not the most practical way to cite, especially if you have many references, and you just want to label it using the author name and publication year, like the following entry:

@article{Balke2020,
   author = {Balke, I. and Zeltins, A.},
   title = {Recent Advances in the Use of Plant Virus-Like Particles as Vaccines},
   journal = {Viruses},
   volume = {12},
   number = {3},
   ISSN = {1999-4915 (Electronic) 1999-4915 (Linking)},
   DOI = {10.3390/v12030270},
   url = {https://www.ncbi.nlm.nih.gov/pubmed/32121192},
   year = {2020},
   type = {Journal Article}
}

If you are happy with the record number as the label, you may stop here. However, if you want to know how to make the label using the author name and year, the you must check some tips I will show below.

Getting author name and publication year as label

I made a simple schematic flowchart below to help you understand the process.

  • Firstly, you need to download this customised EndNote style customised_bibtex_export.ens. Save in the “Styles” directory of your EndNote. Then select this style file using the style manager in “Edit” > “Output Styles”. You have to make sure that this style is selected in the main view window.

  • Note, the style you just downloaded will only give you all author list and publication year. Our goal is to get only last name of first author name and year. Then the next step is to get a piece of R-script below and save it as clean_bibtex_labels.R.

clean_bibtex_labels <- function() {
  args <- commandArgs(trailingOnly = TRUE)
  filename <- args[1]
  print(filename)

  entries <- readLines(filename)
  entries <- stringr::str_replace_all(entries, "(?<=)(,.*)(?=[0-9][0-9][0-9][0-9])", "")
  writeLines(entries, filename)
}

clean_bibtex_labels()
  • After all set up, now you can try to get one bib entry of a reference. I selected a reference in my EndNote and I got the following bib entry:
@article{Balke, I. and Zeltins, A.2020,
   author = {Balke, I. and Zeltins, A.},
   title = {Recent Advances in the Use of Plant Virus-Like Particles as Vaccines},
   journal = {Viruses},
   volume = {12},
   number = {3},
   ISSN = {1999-4915 (Electronic) 1999-4915 (Linking)},
   DOI = {10.3390/v12030270},
   url = {https://www.ncbi.nlm.nih.gov/pubmed/32121192},
   year = {2020},
   type = {Journal Article}
}
  • Run clean_bibtex_labels.R and you can get bib entry we desired:
@article{Balke2020,
   author = {Balke, I. and Zeltins, A.},
   title = {Recent Advances in the Use of Plant Virus-Like Particles as Vaccines},
   journal = {Viruses},
   volume = {12},
   number = {3},
   ISSN = {1999-4915 (Electronic) 1999-4915 (Linking)},
   DOI = {10.3390/v12030270},
   url = {https://www.ncbi.nlm.nih.gov/pubmed/32121192},
   year = {2020},
   type = {Journal Article}
}
You can either run this R script in RStudio or on the terminal by running Rscript clean_bibtex_labels.R.

Horray!!! Then we are all set up and done!

Ruth Kristianingsih
Ruth Kristianingsih
Computational Biologist and Mathematician

#mathematics #computationalbiology #science #dogs