Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

\documentclass{article}
\usepackage[pdftex]{graphicx}
\begin{document}
\end{document}

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 %
  \GPT@error{%
    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%
  }\@ehc
  \pdfoutput=1 %
\fi

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
share|improve this question
    
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 '11 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. –  Lex Apr 15 '11 at 14:06
    
C-c C-t C-p turns on the TeX-PDF-mode of AUCTeX and makes the figures build correctly –  Lex Apr 15 '11 at 14:21
add comment

3 Answers

up vote 7 down vote accepted

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.

share|improve this answer
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 –  Lex Apr 15 '11 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. –  Lex Apr 15 '11 at 14:20
    
@LexFridman you can default emacs to use pdftex by putting this in your .emacs: (setq TeX-PDF-mode t). –  zeroth Nov 5 '12 at 7:36
add comment

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

share|improve this answer
add comment

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".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.