If there is one thing that is annoying when you us pdflatex in Emacs, it is the behavior of Adobe or another commercial product. If you haven’t closed the pdf-file, Emacs or better LaTeX will complain that the pdf-file is still open. I found some tricks in the internet, but I did not manage to implement them properly (you can for example use sumatrapdf, but I wanted to keep my original pdfreader on my computer).
Finally, I decided to use my macro/script program winautomation (www.winautomation.com). I bought this program a few months ago after getting tired of the open source program Autohotkey (which is quite good, but you have to program a lot). Winautomation is just point and click. I wrote a lot of macros that make my life much simpler. For example, I have some scripts that start my subversion backup on my servers, some scripts that open the explorer in a certain directory, a script for logging in at the university, etc.
For the problem above, I did two things: I wrote a script that checks if the pdf-viewer is open, and closes it and integrated it in an Emacs macro.
Here is the script in winautomation:
In Emacs I recorded a macro with C-x ( and C-x ) in which I run a shell command:
Alt-x shell-command Enter
d:\inbox\closepdf.exe (this is the script I wrote with winautomation)
C-c C-c (starting latexing)
…
After some trial-and-error, I now have a Emacs-keyboard macro that exactly does what I want: it closes the pdfviewer program using the winautomation-script and compiles my tex file to pdf.
I changed my settings for latex to always produce a pdf-file by putting the following line in my .emacs
(setq TeX-PDF-mode t)
so now I don’t have to bother about the proper file-format for figures (no converting to ps, etc.).
The last thing I had to do was assign a key to my macro in Emacs. This is done by first naming the keyboard macro I recorded using “Alt-x name-last-kbd-macro” and after that save the macro in my .emacs file with Alt-x insert-kbd-macro and attach a key to it:
Here is the code snippet for the .emacs file
Of course, all this is also possible with autohothey or AutoIt,
Thanks for the hint. See my new post on using Sumatra.
Renger:
I produce PDF files from many programs and work with the free Sumatra PDF reader (http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html). I really like it, partly because it does not lock the pdf-file like the Adobe Reader does. Moreover, if you update a pdf file that you are also viewing with Sumatra, the reader automatically refreshes to the new content. This saves a number of key strokes (or mouse clicks) and this I find very convenient. Moreover, Sumatra loads much faster than Adobe. It does not, however, offer as many fancy features as Adobe.
Jesper