I'm using AUCTeX 11.90 on emacs (recently upgraded from elpa packages) running on Windows 7. I've created a tex file and for some reason only this one particular file gives error msgs when I compile it with pdflatex (C-c C-c): "Undefined control sequence" pointing at \documentclass[10pt]{article} How is this even possible?

I suspected some encoding conflict so I started the 1st line of the document (which btw is the result of an org file export) with: % -*- coding: utf-8; -*-

The problem nevertheless persisted. The bottom part of emacs' buffer now looks like this:

U in left-most corner of buffer


Here are the first few lines from the file's log (ccna1-ch10.log):

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/W32TeX) (preloaded format=pdftex 2015.6.28)  23 MAY 2017 21:49
entering extended mode
 restricted \write18 enabled.
 file:line:error style messages enabled.
 %&-line parsing enabled.
**\input ./ccna1-ch10.tex
./ccna1-ch10.tex:2: Undefined control sequence.
l.2 \documentclass
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

Does this make sense? It stops right at the beginning, won't even go beyond \documentclass[...]{article}. May it have something to do with the .emacs file?

  • 10
    This seems like you're compiling with TeX, not LaTeX...? – Werner May 23 '17 at 19:58
  • Your screenshot says that Emacs saves the buffer in UTF8 with Windows line ending (CR/LF). Your file should compile fine with LaTeX with this line in your preamble \usepackage[utf8]{inputenc}. I also suspect AUCTeX is running TeX and not LaTeX on your file. – Arash Esbati May 23 '17 at 21:15
  • 2
    preloaded format=pdftex -> you're running pdftex rather than pdflatex, I think. – cfr May 24 '17 at 14:50
  • Ok, so why are all other .tex files in the same folder, compiling without problems? They too are are run by pdftex but there are no problems. – WobblyWindows May 24 '17 at 14:56

The reason for this problem, as Werner told you in his comment, is, that you are running TeX instead of LaTeX. You can advise emacs to automatically run LaTeX. To do so, you should have a look at the local variable comments of the file. They should look, e.g., like:

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:

The first and the list line are only magic markers. The second line tells emacs to use the latex mode. The third line tells AucTeX, that the file itself is the main file of the document.

If your file does not have such a section, add it. If the mode line differs, change it.Then save the file and press Strg+C, Strg+N (in emacs syntax C-c C-n) or close it and load it again.

After this, C-c C-c should run LaTeX instead of (plain)TeX.

If this does not help, you can set the mode manually using M-x latex-mode.

  • Unfortunately didn't quite work. I'm still getting an error msg only this time it says: " LaTeX Error: Command \iint already defined. --- TeX said --- Or name \end... illegal, see p.192 of the manual." and an amsmath.sty file opens up in a buffer. Yet, I don't have any math in my tex file. – WobblyWindows May 25 '17 at 16:09
  • 2
    @WobblyWindows I've told you how to make AucTeX run LaTeX instead of (plain)TeX. An already defines \iint would be another problem and therefore another question. And we would need a minimal but working example (MWE) to find the reason and a solution. – Schweinebacke May 26 '17 at 5:42

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.