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

  • Probably next time you'd like to post such a question at TeX.SE :)
    – Dror
    Jul 26 '12 at 8:59

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


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

(TeX-PDF-mode t)

in your ~/.emacs file.

  • very useful answer.... but NB ctrl-c ctrl-t ctrl-p ( not ctrl-c t p )
    – tom
    Aug 30 '18 at 13:52

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


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


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

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.