I have a weird behavior of the TeX-PDF-from-DVI variable from AUCTeX: it keeps being set to "Dvips", and Emacs keeps calling latex instead of pdflatex.

I start with a minimal file test.tex.

Some text.

I also have with a minimal .emacs file.

(add-to-list 'load-path "~/emacs.d/lisp")

(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

When I open test.tex in Emacs, the value of variable TeX-PDF-mode is t, and the value of TeX-PDF-from-DVI is nil. This is what I want. However, when I add the line \usepackage[pdftex]{geometry} as line 2, save the file, restart Emacs and reload the file, the value of TeX-PDF-from-DVI becomes "Dvips". Correspondingly, when I type C-c C-c, the file is compiled to DVI rather than PDF.

After that, I tried customizing variable TeX-PDF-from-DVI to "No DVI to PDF conversion". This adds

 '(TeX-PDF-from-DVI nil)

to .emacs, as expected, but it does not change the value of TeX-PDF-from-DVI in the test.tex buffer, which is still "Dvips". When I restart Emacs and load test.tex, the value of TeX-PDF-from-DVI is still "Dvips". Even adding the line %%% TeX-PDF-from-DVI: nil at the end of the file in the Local Variables section does not help: after reloading the file the value is still "Dvips".

I am not sure how it started. For a long time I only used pdflatex, and Emacs never compiled to DVI. Then I worked with a file that used PSTricks, and Emacs recognized that it needs to compile to PS through DVI. But now I can't restore the original behavior. I have to run (setq TeX-PDF-from-DVI nil) or select Command | TeXing Options | PDF from DVI | Compile directly to PDF every time I start Emacs.

My questions are the following.

  1. How can I make compiling to PDF the default behavior, while preferably retaining parsing the file looking for content that does need to be compiled through DVI?
  2. What sets TeX-PDF-from-DVI besides customization (which apparent does not work)?
  • I have no idea regarding your emacs problem, but you don't need the pdftex option \usepackage[pdftex]{geometry}, simply \usepackage{geometry} is quite enough. Aug 16, 2021 at 16:17
  • Which AUCTeX version do you use? Can you please install the latest version from ELPA with M-x list-packages RET, mark the auctex package for installation with i, and hit x to execute the installation procedure, restart Emacs and try it again? After the restart, also check your installation with M-x list-load-path-shadows RET and check if you have leftovers. Aug 16, 2021 at 16:41
  • @Arash Esbati, I have Emacs 26.3 and AUCTeX 13.0.13. Just in case, I deleted AUCTeX and reinstalled it using list-packages. list-load-path-shadows shows "/usr/share/emacs/site-lisp/latex-cjk-thai/thai-word hides /usr/share/emacs/26.3/lisp/language/thai-word". The value of TeX-PDF-from-DVI did not change: it is still "Dvips". Aug 16, 2021 at 17:24

1 Answer 1


I think I understood the problem. A short answer is that Emacs confused the local style file auto/geometry.el produced by editing an unrelated file geometry.tex with a style file corresponding to the package geometry.sty.

Before I worked with test.tex, I edited and compiled geometry.tex in the same directory. Emacs created the local style file auto/geometry.el. Since geometry.tex used PSTricks, auto/geometry.el contained the instruction (TeX-run-style-hooks "latex2e" ... "pstricks" ...). In turn, the PSTricks style hook contained in pstricks.el reasonably assigns "Dvips" to TeX-PDF-from-DVI. The *Messages* buffer says that after opening test.tex, Emacs loaded a global style file ~/.emacs.d/elpa/auctex-13.0.13/style/geometry.elc for the geometry package, and then it loaded auto/geometry.el as a local style file for that package. That's why TeX-PDF-from-DVI ended up with the value "Dvips".

This shows that it is dangerous to give your file the same name as one of the packages loaded by some file in the same project. I guess the AUCTeX manual warns about this in section 5.5: "Please note that all matching files found in TeX-style-path are loaded, and all hooks defined in the files will be executed". Still, it may make sense to introduce a difference between style files for LaTeX packages and style files for local files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .