[Tex/LaTex] Customizing preview-latex command to use LaTeX when in TeX-Pdf mode

auctexemacspreview

In short: Is there a way to tell preview-latex to NOT use pdflatex instead of just toggling TeX-Pdf mode every time I want to re-generate previews?

I have a somewhat odd setup. AucTeX + GNU Emacs 24 on Mac OSX 10.6.8, operating with Skim as my pdf viewer.

I am using a makefile for document compilation that calls latex + bibtex + simpdftex to generate a PDF with synctex enabled. (I use psfrag and .eps files which is why latex is used instead of pdflatex). When Auctex is in TeX-Pdf mode (C-c C-t C-p) I can use synctex for forward and inverse search and C-c C-c and a Make command for quick compilation. (Without being in TeX-Pdf mode, forward-seach (C-c C-v) stops with a .dvi not found error) So far, everything works great, as expected.

However, preview-latex doesn't like this setup. When in TeX-Pdf mode, preview-latex wants to use pdflatex as the compilation command, but this doesn't work with my document and errors with a no images found. If I turn off TeX-Pdf mode, re-run preview-latex (C-c C-p C-d), PNGs are created and correctly placed in the document.

The Preview LaTeX Command customization option seems to be specifically related to what is inserted into the tex document and not the external compilation tool.

Best Answer

You can turn off pdf output by customizing preview-LaTeX-command-replacements like M-x customize-variable RET preview-LaTeX-command-replacements RET. Then add a Named Replacement, and use the name preview-LaTeX-disable-pdfoutput. I can't remember since it's been a while, but you might have to change preview-image-type to dvipng as well. I may have done that to avoid some other problem on my machine.

I think that should work but if not, you can customize preview-LaTeX-command and change the %l to %(latex) %S or something similar. Hopefully that wouldn't mess up the rest of the processing since it's hoping for pdf output.

Related Question