LaTeX error "Repeated entry---line 7 of file refs.bib": cause and fix
Two entries of the .bib data have the same key. BibTeX keeps the first one and skips the one at the line it names, so a \cite of that key always shows the first entry. The message is in the BibTeX log, the .blg file. The example writes its .bib file from inside the document with filecontents*, so that you see both parts together.
Why it happens
- The same source was added twice, for example by two exports from a reference manager.
- Two different sources got the same key, such as two works by one author from the same year.
- The keys differ only in upper and lower case. BibTeX treats
Knuth1984andknuth1984as the same key.
How to fix it
- Go to the line the message names and delete the entry if it is a copy.
- For two different sources, make the keys unique, for example
knuth1984aandknuth1984b, and update the\citecommands.
A document that produces the message
\begin{filecontents*}[overwrite]{refs.bib}
@book{knuth1984,
author = {Donald E. Knuth},
title = {The TeXbook},
publisher = {Addison-Wesley},
year = {1984}
}
@article{knuth1984,
author = {Donald E. Knuth},
title = {Literate Programming},
journal = {The Computer Journal},
year = {1984}
}
\end{filecontents*}
\documentclass{article}
\begin{document}
See \cite{knuth1984}.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}Tools run in this order: pdflatex → bibtex.
The corrected document
\begin{filecontents*}[overwrite]{refs.bib}
@book{knuth1984a,
author = {Donald E. Knuth},
title = {The TeXbook},
publisher = {Addison-Wesley},
year = {1984}
}
@article{knuth1984b,
author = {Donald E. Knuth},
title = {Literate Programming},
journal = {The Computer Journal},
year = {1984}
}
\end{filecontents*}
\documentclass{article}
\begin{document}
See \cite{knuth1984a} and \cite{knuth1984b}.
\bibliographystyle{plain}
\bibliography{refs}
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.