Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I configure Emacs to run pdflatex rather than latex on a LaTeX file when I type C-c C-f (tex-file)?

share|improve this question
Probably next time you'd like to post such a question at TeX.SE :) – Dror Jul 26 '12 at 8:59
up vote 11 down vote accepted

You can do this by setting latex-run-command; see the the emacs manual. Something like this in your .emacs should do it:

(setq latex-run-command "pdflatex")

share|improve this answer
Thanks! That did the trick. – John D. Cook May 19 '10 at 13:45

You can temporarily switch AucTeX to pdf mode with CTRLctp. To make this change permanent set

(TeX-PDF-mode t)

in your ~/.emacs file.

share|improve this answer

Should it not be

(setq TeX-PDF-mode t)

in .emacs?

My version of emacs (GNU 24) complains when I just have (TeX-PDF-mode t).

(Or maybe this is because I am using AucTeX, which is awesome BTW.)

share|improve this answer

After trying several approaches, the one that worked for me (also for AucTeX) was

M-x customize-group for TeX-command, and rewriting "Latex Command" to pdflatex.

(Changing the viewer to open the pdf wasn't even necessary, it just worked.)

(idea from here.)

share|improve this answer

I tried to use pdflatex with Auctex and (TeX-PDF-mode t) or (setq TeX-PDF-mode t) in my ~/.emacs didn't work, so here is what I found out:

There is a variable and a function with the same name: TeX-PDF-mode. One can either set the variable directly with (setq TeX-PDF-mode t) or use the function (TeX-PDF-mode t). But the variable is not only buffer local, but automatically buffer local.

Buffer local means there is a default value for the variable and every buffers can have a local binding. Changes to the variable in buffers without a local binding change the default value. Changes to the variable in buffers with a local binding affect only the local binding.

Automatically buffer local means that every change to the variable becomes automatically buffer local, if there wasn't already a local binding it gets created. There is no way to change the default value with setq, one has to use setq-default.

So, using (setq TeX-PDF-mode t) or (TeX-PDF-mode t) in ~/.emacs should have no effect on yet to be created buffers. One has to use either (setq-default TeX-PDF-mode t), or better the provided function (TeX-global-PDF-mode t).

share|improve this answer

Your Answer


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.