I have a tex file citing some references from a bib file. I want to reformat (i.e. regenerate) all the citation keys in the bib file using JabRef and automatically propagate the changes to the tex file. Does someone know a way of automatically keeping both files synchronized?

  • 2
    Welcome! You question isn't very clear. Citation keys are plain text - you can't format them. If you mean that you want to change them, how would the system know which key to substitute for which? The key is the way the system recognises which .bib entry you mean to cite. If you change the key, there is nothing for it to recognise. That said, if you use Biblatex, you can put the old key into the ids field and then the entry will still be found, even though the .tex file only uses the old key. This is what I do when I want to change a citation key. That way, existing files still work.
    – cfr
    Feb 16, 2018 at 1:27
  • The other thing you could do is write something like a sed script and apply it to the two files. Then they'd be in sync because you'd make the same changes in both. But you'd need to make sure to avoid spurious matches. Possibly gawk might do it a bit more safely, if there's a risk of matches on other lines. Whether JabRef would like your doing this I know not, but they are all just text files, after all, so you can use the standard text processing tools on them.
    – cfr
    Feb 16, 2018 at 1:30
  • With JabRef, one can press Ctrl+G to generate BibTeX keys following a pattern. When doing that in JabRef, only the bib file changes, but not the tex files referencing the bib file. I think, this is a feature wish for JabRef. You could bring up that in the forum or just go ahead an implement it directly in JabRef's source.
    – koppor
    Feb 16, 2018 at 6:26
  • 1
    Thanks for the comments. I updated the question. I think now it is a bit more clear. I want to do exactly what @koppor said. I will take a look into JabRef's code to see what I can do. Feb 17, 2018 at 12:25

1 Answer 1


This simple project solved the key and cite renaming problem:


It's a simple code, you must

  1. Clone the bibtex-rename with git clone https://github.com/dmpalyvos/bibtex-rename

  2. Rename the bibkey of your file sample.bib, and save as sample_new.bib.

  3. Install the bibtex parser: pip install bibtexparser.

  4. Execute python transform.py --tex main.tex --oldbib sample.bib --newbib sample_new.bib --out out.tex.

Check and ensure that the itens are in the same order,and if you are citing the BibTeX item with \cite{bibkey}.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .