Ads by Google

Sunday, April 13, 2008

Making AucTeX launch the Windows Acrobat Reader

When I compile documents using AucTeX, I used to manually open and close the generated pdf by navigating to the file location and opening the file using Windows based Acrobat reader.

The Reader locks the file when in use, so if you recompile the document when the pdf is still open by the Reader, you'd get the "can't write to output file" error.

One workaround I used was, the cygwin based xpdf viewer which doesn't lock the file. But you'd have to refresh the file every time something changed, by hitting 'r' in the xpdf application.

The problem with the default AucTeX install was that it had the start "" %o as the entry for View which didn't do anything. Even though I don't use that feature, I thought, let's get this to point to Acrobat Reader and save it.

Turned out, you need to customise TeX-output-view-style. Setting it to

start "acrord32" %o
acrord32 %o

didn't work. Finally, one poster on the AucTeX mailing list give the answer which made it self evident. Since I was using cygwin, he suggested I use cygstart instead of start.

That worked like a charm and now my TeX-output-view-style looks like

Its value is
(("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "dvips %d -o && start \"\" %f")
("^dvi$" "." "yap -1 %dS %d")
("^pdf$" "." "cygstart acrord32 %o")
("^html?$" "." "start \"\" %o"))