#83 texify: DDE interaction with AR

TeXify (10)
Robert J. Ragno

I have a suggestion that might help people who want to create PDF
files or just like the features of Acrobat as a viewer.

A minor
pre-suggestion first - texify is great, but it would be nice if it
preserved the return value of latex or pdflatex instead of always
succeeding (returning 0).

Creating PDF files is very
convinient with pdflatex. However, you do not get the nice ability
of Yap to automatically reload the DVI document. Worse, Acrobat
grabs exclusive access to the PDF and will not even allow it to be
overwritten. This severly hinders interactive document
creation and preview.

I have devised a solution to this for
myself, and I think it could be incorporated into the MikTex tools
(if not pdflatex, then texify). It is to check before compiling if
the output PDF exists. If so, DDE is used to close the file in Acrobat
Viewer. After compiling, DDE is used to reopen in in Acrobat Viewer
(if Acrobat is running) - giving an effect much like Yap. Focus even
remains on the command prompt.

(This could be tweaked
slightly to be more conservative, only closing and reopening it if
the file exists and is not writable. It doesn't seem possible to
check if it is open in Acrobat, though. It also is possible to go to a
particular page in Acrobat, but this seems outside the scope of the
MikTeX tools themselves.)

I can give the code I use, although
that is simple enough to follow, I think. It is a NT batch file, and
relies on a "dde.exe" program of mine that merely sends DDE
commands. (This would not be the way to do it in an integrated code
segment, of course. I've also hard- coded in a document name for
simplicity, instead of using the command-line variable).

IF EXIST thesis.pdf dde acroview control
[DocOpen(thesis.pdf)] [DocClose(thesis.pdf)]

texify -c -p

IF errorlevel 0 IF EXIST thesis.pdf dde acroview
control [DocOpen(thesis.pdf)]

The whole actual
ptexify.bat file I use is:

1 @echo off
2 set d=%~d1
3 set
4 set n=%~n1
5 set o=%d%%p%%n%.pdf
6 IF EXIST "%o%"
dde acroview control "[DocOpen(\"%o%\")]"
7 echo compiling latex to pdf...
texify -c -p %1
9 IF errorlevel 0 IF EXIST "%o%" dde acroview control

Anyway, would that be useful enough to

  • Rob