I get this error when trying to compile a pdf with Lyx 2.1:

This is pdfTeX, Version 3.1415926-2.6-1.40.14 (TeX Live 2014/dev) (format=latex 2015.4.2)  28 JUL 2015 12:45 entering extended mode  restricted \write18 enabled.  %&-line parsing enabled.
**rationale.tex (./rationale.tex LaTeX2e <2011/06/27> Babel <3.9h> and hyphenation patterns for 2 languages loaded.


! LaTeX Error: Missing \begin{document}.

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


                                                   l.1 <
     script>window.googleJavaScriptRedirect=1</script><script>var m={navigat...

You're in trouble here.  Try typing  <return>  to proceed. If that doesn't work, type  X <return>  to quit."

Here is the output .tex file minimal example:

%% LyX 2.1.0 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.

It generates the same error for compilation.

  • The main error is: ! LaTeX Error: Missing \begin{document}. Check the latex file you are working on and make sure it contains \begin{document] – Leucippus Jul 28 '15 at 19:02
  • @Leucippus He's using LyX, so it's impossible to avoid having \begin{document}, I think. – Torbjørn T. Jul 28 '15 at 19:36
  • deamondave: Have you added anything to the preamble, and if yes, what? Can you make a minimal example (basically make a copy of your file and remove as much content and custom setup as possible without removing the error), export that to LaTeX code, and add it to your question? – Torbjørn T. Jul 28 '15 at 19:39
  • yes. Lyx on Fedora 20. – daemondave Jul 28 '15 at 19:39
  • 2
    latex didn't even finish reading article.cls. is there anything in the .tex file before the \documentclass line? something that includes a <script>, for instance? (i'm totally ignorant about lyx, but when the log complains about line 1, ...) – barbara beeton Jul 28 '15 at 19:53

The situation seems quite clear: the article.cls file is fetched from


while it should be in


Somebody or something installed some texmf-compat subtree under texmf-local and this is the cause of your problem. Possibly the cause is having installed LaTeX2HTML, which is an obsolete and unsupported program.

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.