[OS X TeX] TeXShop Engine to use Acrobat as previewer

Ramón Figueroa-Centeno ramonf at hawaii.edu
Sat May 22 13:00:58 CEST 2010


Just to see if it could be done, I wrote a TeXShop engine that uses Acrobat
as a previewer. 

(It has a neat trick, that might be useful, i.e., how to close a TeXShop
preview window at the end of the execution of an engine).

Save it in, say, "~/Library/TeXShop/Engines/Acrobat-Preview.engine" and make
it executable.

To us it place the line "% !TEX TS-program = Acrobat-Preview" (no quotes, of
course) at the beginning of your LaTeX file (first 20 lines). Then Typeset.

It will typeset, show the result in Acrobat (closing any previous preview)
and then close in the background the preview that TeXShop created.

Now, obviously it does not do SyncTeX, but it does remember the page.

I only tested it with Acrobat Pro (version 9.0.0). If you want to test it
with Acrobat Reader you have to change the line 

tell application "Adobe Acrobat Pro"

to reflect that.



--------------------------code starts below this


name=$(basename "$1" .tex)

# Change this line to whatever typesetting command you like that produces
pdflatex --file-line-error --shell-escape --synctex=1 "$1"
# comment the line above and uncomment the one below if you wish to use an 
# installed TeXShop engine. Here we use pdflatexmk as an example.
~/Library/TeXShop/Engines/pdflatexmk.engine "$1"

# Close any preview taht already exists (if any) and ope the new one.
/usr/bin/osascript  <<END
tell application "Adobe Acrobat Pro"
	set pg to 1
		set pg to page number of the PDF Window of the document "$name.pdf"
		close document "$name.pdf"
	end try
	open POSIX file "$basefname.pdf"
		goto PDF Window of the document "$name.pdf" page pg
	end try
end tell

# We close the pdf window in TeXShop
close_window="tell application \"TeXShop\" to close (every window whose name
contains \"$name.pdf\")"

nohup /usr/bin/osascript  -e "$close_window" &

View this message in context: http://macosx-tex.576846.n2.nabble.com/TeXShop-Engine-to-use-Acrobat-as-previewer-tp5087826p5087826.html
Sent from the MacOSX-TeX mailing list archive at Nabble.com.

More information about the macostex-archives mailing list