Is there an established way to spell check .bib files? There's a previous question on spell checking TeX files but I could not find much about .bib files.

I use aspell to spell check my .tex files. Running aspell on a .bib file is very tedious as aspell is not aware of the syntax. I tried extracting only the title fields with bash (grep '\btitle = {' bibliography.bib | sed 's/title =//g' | sed 's/{//g' | sed 's/},//g' | sed 's/}//g'), but this is not entirely satisfactory either. My .bib file is rather long (about 26000 lines), and I have many non-English citations. Is there a good way to filter .bib files by language?

Spell checking only the citations used in a particular paper would be more manageable. I've seen recommendations to spell check the .bbl file, but aspell handles this worse than it does .bib files. Limiting just to titles is okay (grep '\field{labeltitle}\|\field{title}' file.bbl | sed 's/\\field{labeltitle}{\([^}]*\)}/\1/g' | sed 's/\\field{title}{\([^}]*\)}/\1/g' | sed 's/{//g' | sed 's/},//g' | sed 's/}//g') but I'd rather spell check the entire citation (without resorting to some absurdly long bash command to parse the .bbl file).

Any ideas would be appreciated.

| improve this question | | | | |
  • 1
    Mhhh, I guess spell checking for .bib files is not so simple. Only very few of the fields in a .bib file can be spell checked: title, location (maybe journal). Names don't really lend themselves to spell checking, and even the titles of scientific papers may contain many words that are too much for your average spell checker (without you adding them). The second thing is that you have to double check your .bib file for correctness anyway, this is a job that can hardly be automated and involves checking the order of names, the entry type etc. ... – moewe Feb 8 '18 at 6:26
  • 1
    ... So when you are doing that you might as well check if the spelling is the same as on the work you cite. That said, Biber and I assume also bibtool can filter .bib files by language and can also remove fields you are not interested in, but they can't do a spell check for you. – moewe Feb 8 '18 at 6:26
  • I'll look into filtering and making a better script to extract the fields of interest. Thanks. – Ben Trettel Feb 9 '18 at 6:46

Some ideas, not a perfect solution:

  • Use \nocite{*} to generate a PDF, then do the spellcheck there. Or, works surprisngly well, open the PDF in Word.
  • Try codespell: https://github.com/codespell-project/codespell
    It will not give perfect results, but can be configured with whitelists an blacklists.
| improve this answer | | | | |

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.