I have a LaTeX file using lots of PDF figures (mostly because converting figures to EPS is a waste of disk space), so it requires to use pdflatex.

I added these lines to the end of my main file:

%% Local Variables:
%% latex-run-command: pdflatex
%% End:

Whenever when I open the file, Emacs asks me whether to evaluate these settings, and I confirm. However, C-c C-f still runs latex \\nonstopmode\\input input.tex.

Why doesn't it work? (this is the question I should point out clearly)

Also in Customize the setting of latex-run-command still is Standard.

After a significant waste of time, I wrote a Makefile that builds my document (keeping the PDF open in evince). So I use compile to build the file now.


When I run C-c C-f, the output starts like this:

latex \\nonstopmode\\input Farbe.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/TeX Live for SUSE Linux) (preloaded format=latex)

When I run pdflatex manually, the output starts like this:

pdflatex Farbe
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/TeX Live for SUSE Linux) (preloaded format=pdflatex)

So the preloaded format is different, causing errors like

! LaTeX Error: Cannot determine size of graphic in RGB-Cube-3D.pdf (no Bounding

Also, using latex-run-command: "pdflatex" makes no difference: pdflatex is not being used.

More details:

When I load the file (having changed the settings to the following)

%% Local Variables:
%% latex-run-command: "pdflatex"
%% End:

and then do C-h v latex-run-command, I get:

latex-run-command’s value is "pdflatex"
Original value was "latex"
Local in buffer Farbe.tex; global value is "latex"

  This variable’s value is file-local.
  This variable may be risky if used as a file-local variable.

Command used to run LaTeX subjob.
LaTeX Mode sets ‘tex-command’ to this string.
See the documentation of that variable.

But still, the command run is not pdflatex, but latex!

More info (2019-11-28)

My Emacs is 25.3.1, and in loaddefs.el I have:

(defvar latex-run-command (purecopy "latex") "\
Command used to run LaTeX subjob.
LaTeX Mode sets `tex-command' to this string.
See the documentation of that variable.")

And tex-mode.el contains:

(setq-local tex-command latex-run-command)

Even when I tried this, it did nor work:

%% Local Variables:
%% latex--command: "pdflatex"
%% eval: (add-hook 'latex-mode-hook (lambda () \
%%  (setq latex-run-command "pdflatex")))
%% End:

I also had tried variants setq-local, tex-command instead of latex-run-command, but it all did not work.

Neither does it work after having used set-variable interactively to set latex-run-command, nor does it work after I had set the variable in "Customize Option: Latex Run Command".

  • @Drew: Please just read the whole question, especially the part about "C-c C-f". Actually I don't understand your comment.
    – U. Windl
    Apr 8, 2019 at 19:55
  • I tried a tex file of mine with emacs -Q and your local variables. After C-c C-f it does say $ latex \\nonstopmode\\input tvFellerprobe.tex This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018/Arch Linux) (preloaded format=latex). Is it the same for you or not, when starting the things with emacs -Q
    – andrej
    Apr 8, 2019 at 20:16
  • @andrej: Yes, it's the same. I'll update the question with more details.
    – U. Windl
    Apr 8, 2019 at 20:31
  • Have you tried auctex? It is a much richer mode than the native latex mode and might have something to accommodate your needs.
    – NickD
    Apr 8, 2019 at 22:20
  • 1
    I'm pretty sure I provided the answer: the mode function which sets tex-command from latex-run-command runs before the latter is given its file-local value.
    – NickD
    Apr 9, 2019 at 0:00

2 Answers 2


One problem is the syntax: the value is a string so you need to say so by surrounding it with double quotes. However I could not get this to work with the latex-run-command variable. However tex-command seems to work (for some value of "work"):

%% Local Variables:
%% tex-command: "pdflatex"
%% End:

EDIT: The problem with latex-run-command may be a sequencing problem: when the file is opened, does the mode function get run and then local vars are set? or the other way round? If the mode function is run first, that would explain why the latex-run-comand setting is ineffective: the mode function does

(setq-local tex-command latex-run-command)

so it is probably setting it to the old value, before the local variable setting takes effect. You can try customizing latex-run-command and restarting emacs: I suspect that that would work.

  • However customize says for latex-run-command: "LaTeX Mode sets ‘tex-command’ to this string."
    – U. Windl
    Apr 8, 2019 at 20:42
  • It sounds like a bug. Consider the above as a possible workaround.
    – NickD
    Apr 8, 2019 at 20:52
  • Maybe not a bug: see my EDIT.
    – NickD
    Apr 8, 2019 at 20:57
  • On "You can try customizing latex-run-command and restarting emacs": That was not the question: I want to select LaTeX mode for a particular file, not for all LaTeX files.
    – U. Windl
    Apr 8, 2019 at 21:06
  • 1
    ... or rather you cannot do it by setting latex-run-command locally in the file. As I demonstrated above, you can set tex-command locally: that works fine.
    – NickD
    Apr 8, 2019 at 23:59

The documentation does not match the implementation, or the implementation is broken: The variable latex-run-command was changed from "latex" to "pdflatex", but command tex-file (found in latex-mode-map) still uses latex \\nonstopmode\\input.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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