I've been using Emacs + AUCTeX for several years now, and all of a sudden I started getting the follow error on all documents that have compiled fine before:

ERROR: Package pdftex.def Error: PDF mode expected, but DVI mode detected!

This error can be duplicated for me with the following very basic document. From within Emacs I type C-c C-c and then choose LaTeX. That's what I've always done, and I assume AUCTeX automatically determined to run pdflatex command. When I run pdflatex from the command line, the tex file compiles without errors.


The error comes from the [pdftex]. In other words, \usepackage{graphicx} works just fine without [pdftex]

Specifically, the error comes from pdftex.def:

\ifnum\pdfoutput<1 %
    PDF mode expected, but DVI mode detected!\MessageBreak
    If you are using `latex', then call `pdflatex'.\MessageBreak
    Otherwise check and  correct the driver options.\MessageBreak
    Error recovery by switching to PDF mode%
  \pdfoutput=1 %

It seems that \pdfoutput is not being set to 1, and perhaps for all the time I've used AUXTeX in the past, it was set to 1. What has changed?

I'm using:

  • Ubuntu 10.10
  • pdfTeX 3.1415926
  • AUCTeX 11.85
  • Emacs 23.1.1
  • How are you compiling? LaTeX or pdfLaTeX? If runing under LaTeX \pdfoutput has a different value, but you are trying to force graphicx to load the pdftex driver which will not work with regular latex, it need pdflatex. In any case one never need driver option to graphicx unless one is using dvipdfx (or perhaps xelatex)
    – daleif
    Apr 15, 2011 at 13:48
  • How can I compile in AUCTeX using pdfLaTeX? When I type C-c C-c I've always only had the LaTeX option which it always seemed to run pdfLaTeX automatically. Apr 15, 2011 at 14:06
  • C-c C-t C-p turns on the TeX-PDF-mode of AUCTeX and makes the figures build correctly Apr 15, 2011 at 14:21

3 Answers 3


The only thing that has changed is that pdftex.def now tests if you are using the correct engine/mode for this driver file. And you get an error as you are obviously using the wrong mode. Remove the option. It will then work with latex/dvi-output and pdflatex/pdf output. graphics is clever enough to choose the correct driver file.

  • 1
    Ah, interesting, I removed the pdftex option. But now, it's giving me an error when I try to include pdf figures, saying "Cannot determine size of graphic in bla.pdf (no BoundingBox)". If I run pdflatex from the command line, I don't get this error. I get it only when I compile through AUCTeX with C-c C-c and then selecting LaTeX Apr 15, 2011 at 14:04
  • Okay found the fix for the second problem: C-c C-t C-p turns on the TeX-PDF-mode of AUCTeX and makes the figures build correctly. Apr 15, 2011 at 14:20
  • @LexFridman you can default emacs to use pdftex by putting this in your .emacs: (setq TeX-PDF-mode t).
    – nickpapior
    Nov 5, 2012 at 7:36

I was getting a similar error with texstudio

!LaTeX Error: Cannot determine size of graphic in xxxx.pdf (no BoundingBox).

The error was caused because the "build & view" was set "dvi->pdf chain".

The solution is to set

configuration->build->build & view->compile & view

or "pdf chain".


You have to use pdflatex

If you are using latex ', then call pdflatex'. So make one with Texmaker, that he uses pdflatex.

Options -> Configure Texmaker/TexStudio.. - Compile> Fast -> pdflatex + ViewPDf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .