How can I configure Emacs to run pdflatex rather than latex on a LaTeX file when I type C-c C-f (tex-file)?
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")
Should it not be
(setq TeX-PDF-mode t)
My version of emacs (GNU 24) complains when I just have
(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 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