4

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
1,7c1,7
< \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
(./bugtext.tex
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.
...                                                 
l.1 
     ��%\documentclass[10pt]{scrartcl}
?
! 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?

Goswin
  • 105
  • 2
    Sounds like the Unicode byte order mark has struck again http://tex.stackexchange.com/questions/10474/latex-baffled-by-bom-unicodes-byte-order-mark – 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

1 Answers1

11

Since you are using vim you can use

:setlocal nobomb
:wq

see

https://stackoverflow.com/questions/295472/how-do-i-remove-the-bom-character-from-my-xml-file

David Carlisle
  • 757,742