1

I have a big BibTeX file with entries with keys such as smith-jones-2011 and shah-2018. I'd like to rename these keys into Smith2011 and Shah2018 instead but I don't want to break the LaTeX files that refer to the old keys. Is there a good automated way to change all of the keys in the BibTeX file and updating the LaTeX files?

3

.bib files have no knowledge about the .tex documents they are used in, so a .bib file can't magically go back through all your files and change the citation keys.

A simple search-and-replace job across all your .tex might be enough for you. If your database is big you may want to try and automate this by obtaining a list of old and new keys that can be worked through one-by-one.


If you are using biblatex (with Biber) you could use the ids field to keep the old name alive. See kregkob's answer to bibtex with multiple aliases for the same reference and also PLK's answer to Having several keys refer to the same bibliography entry

@article{Smith2011,
  ids       = {smith-jones-2011},% <- old key
  author    = {Jane Smith and Emma Jones},
  title     = {Title},
  journal   = {Journal of Stuff},
  year      = {2011},
  volume    = {12},
}

A bit of a hack would be to crossref the old name to the new one

@article{Smith2011,
  author    = {Jane Smith and Emma Jones},
  title     = {Title},
  journal   = {Journal of Stuff},
  year      = {2011},
  volume    = {12},
}

@article{smith-jones-2011,
  crossref = {Smith2011}
}

as suggested by frabjous in Can a bibtex entry be given more than one reference name?. This need not work with all .bst files and can lead to duplication in the bibliography and other weird side-effects if both names are used in the same document.


If you are exclusively using biblatex (with Biber) you should be fine with ids. Otherwise I would suggest the search and replace solution.

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.