How to Fix the BibTeX Error “White Space in Argument”
At a glance
- 1. Find the argument
Open the .aux file named in the error and check the reported line, especially citation keys and bibliography filenames.
- 2. Remove spaces
Use citation keys and BibTeX database filenames without whitespace; replace spaces in filenames with underscores.
- 3. Rebuild the bibliography
Run LaTeX, BibTeX, then LaTeX twice so the corrected auxiliary data and references are used.
The BibTeX error “White space in argument” usually means BibTeX found a space where it expects a compact argument, such as a citation key, bibliography database name, or bibliography style name. The error commonly points to a generated .aux file, so the reported line may not correspond directly to a line in your .tex source.
The quickest fix is to inspect the exact auxiliary-file command named in the error, remove whitespace from the relevant key or name, and rebuild the bibliography.
Check the reported .aux line
When you compile a LaTeX document, LaTeX writes commands to an auxiliary file. BibTeX reads that file to learn which citation keys, bibliography databases, and bibliography style to use. Look at the .aux file named in the BibTeX message and inspect the indicated line. Common commands include:
\citation{key}: records a citation key.\bibdata{references}: records the bibliography database filename, without the.bibextension.\bibstyle{plain}: records the bibliography style.
Spaces are valid in normal bibliography text, such as an article title. The problem is whitespace inside an argument that BibTeX expects to be an identifier or filename, such as a citation key, database name, or style name. For example, \citation{doe 2020} contains a space in its key, and \bibdata{my references} contains a space in the database name.
Fix the citation key or database name
If the error points to \citation{...}, check the key inside the braces. Citation keys are identifiers, not descriptive phrases. In your .bib file, use a key such as doe2020 or doe_2020, then use that exact key in \cite{...}. Avoid spaces in citation keys; use \cite{doe2020} with a matching doe2020 key in the .bib file.
If the error points to \bibdata{...}, rename the .bib file to remove spaces. For example, change my references.bib to my_references.bib and write \bibliography{my_references}. Do not include the .bib extension in the usual \bibliography{...} command.
If the error points to \bibstyle{...}, remove whitespace from the style name and verify that the intended .bst style file is available.
Also check for accidental spaces at the beginning or end of an argument, and for manually edited .aux files. Fix the source .tex or .bib file rather than relying on a temporary edit to .aux, because LaTeX regenerates auxiliary files during compilation.
Minimal working example
Save this LaTeX document as main.tex:
\documentclass{article}
\begin{document}
A citation looks like this: \cite{doe2020}.
\bibliographystyle{plain}
\bibliography{references}
\end{document}
Save this bibliography as references.bib in the same folder:
@article{doe2020,
author = {Jane Doe},
title = {An Example Article},
journal = {Example Journal},
year = {2020}
}
Here, doe2020 is the key, and references is the database name. Neither has whitespace. The article title may contain spaces because it is a field value, not a key or database name.
For a standard BibTeX workflow, run pdflatex main, bibtex main, then pdflatex main twice. In a graphical editor, choose its BibTeX bibliography build sequence or clean and rebuild the project. The first LaTeX run creates the .aux file, BibTeX processes it, and later LaTeX runs incorporate the resulting bibliography.
Common mistakes
- Changing only the visible citation text: The author name shown in the bibliography is not the citation key. Check the key after
@article{(or another entry type) in the.bibfile and the key inside\cite{...}. - Adding
.bibto\bibliography: Use\bibliography{references}, not\bibliography{references.bib}. - Editing the wrong file: The error may name
main.aux; inspect that file, but make the lasting correction in the.texsource or the.bibfilename. - Forgetting to rerun the tools: After correcting the source, rerun LaTeX and BibTeX in the proper order. If stale auxiliary files keep causing errors, clean the generated files and rebuild.
If the reported line contains no obvious space, inspect the complete argument and nearby generated commands for an unexpected key, a filename with whitespace, or an old entry left in the .aux file. A clean rebuild can help distinguish stale generated data from a remaining source error.
References
- BibTeXing, by Oren Patashnik
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.