I use Linux Mint with gvim_7.3.429 in order to edit my TeX files. Recently I got the following result when comparing two files:

goswin@mycomp diff oktext.tex bugtext.tex
< \documentclass[10pt]{scrartcl}
< \usepackage[utf8]{inputenc}
< \usepackage[T1]{fontenc} 
< \begin{document}
< Hello world
< \end{document}
> \documentclass[10pt]{scrartcl}
> \usepackage[utf8]{inputenc}
> \usepackage[T1]{fontenc}
> \begin{document}
> Hello world
> \end{document}

The files are definitely different, since the first one compiles properly, while the second one crashes with the following output:

goswin@mycomp pdflatex bugtext
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, nohyphenation, ngerman, german, german-x-2009-06-19, ngerman-x-2009-06-19, spanish, galician, catalan, loaded.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
! Emergency stop.

How can I find out what is going on? (The file I need to debug is actually much larger; I deleted almost all of its content, but the error remains.) And, by the way, why is it loading all of those hyphenation files without my telling it to do so?

  • 2
    Sounds like the Unicode byte order mark has struck again tex.stackexchange.com/questions/10474/… – Au101 Sep 14 '16 at 18:54
  • @Au101: Indeed. But the answer I found at your link is "Avoid BOMs in TeX or LaTeX documents, they are neither necessary nor recommended", which does not help me. So far I did not even know what a BOM is, and I certainly would love to avoid it, but it crept in without my asking and I do not know how to remove it. – Goswin Sep 14 '16 at 19:13
  • In most editors it should be enough to delete the first line then retype it – David Carlisle Sep 14 '16 at 19:18
  • @David Carlisle: I already tried retyping the first line and it did not work. What did work was creating an entirely new file and copy-pasting the content into it. But if the file is large (as is mine) such a proceeding would often be quite a nuisance. – Goswin Sep 14 '16 at 19:52

Since you are using vim you can use

:setlocal nobomb



  • 6
    What a great editor, so intuitive and easy and definitely not emacs. :) – Paulo Cereda Sep 14 '16 at 19:30
  • 1
    @PauloCereda stackoverflow.com/questions/3859274/… – David Carlisle Sep 14 '16 at 19:31
  • I am using vim version_7.3.429 and I get the message "E518 unkown option: nobom". Is my version of vim obsolete? – Goswin Sep 14 '16 at 19:57
  • 2
    @Goswin I'm struggling not to say "all versions of vim are obsolete":-) As egreg an Paulo know, I've never used vi(m):-) I had a hint from Paulo, and then I found the link on stackoverflow to confirm but that's the extent of this emacs user's vim knowledge, sorry. – David Carlisle Sep 14 '16 at 20:09
  • 1
    @Goswin sorry try now, Paulo fixed my typing – David Carlisle Sep 14 '16 at 20:18

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.