[OS X TeX] Can a TeXShop engine give the PDF name?
cgg.lists at gmail.com
Tue Dec 3 18:51:13 EST 2013
On Dec 3, 2013, at 10:26 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> I'm writing a TeXShop engine for Sweave. On a complicated project, it might be that the current file is Chapter.Rnw, but the engine will eventually run pdflatex on Book.tex, producing Book.pdf. My engine can determine all of these names from the Chapter.Rnw file.
> Is there a way for the engine to tell TeXShop that the PDF from the current typesetting operation is Book.pdf?
> I have found that using Applescript to open Book.pdf is not quite right: if the preview was already open from typesetting Book.tex, then I get a second copy. (I don't get two copies from "open"ing it twice; there's something different about the way TeXShop opens it as a preview than opening it just as a file on its own.)
> Thanks for any help.
I would love to be able to do the same thing reliably.
Here’s a piece of an engine I use to achieve something similar. The part below is the piece that tells TeXShop to open the correct pdf file. I’m not sure if it’s the same thing you tried via Applescript. My version doesn’t work very well in Mountain Lion or Mavericks; it worked great before that. (Actually, it can cause TeXShop to crash in Mavericks; I’ve reported this to Dick Koch.) Applescript is pretty finicky, though, so I thought I’d post it in case it gives you an idea for something that actually works.
It would be really cool (and useful to me) if TeXShop supported some way for engines to communicate the name of the pdf file back to TeXShop for viewing.
osascript << EOF
tell application "TeXShop"
open posix file "$cwd/foo.pdf"
set index of window "$1:foo.pdf" to 1
tell document "$1:foo.pdf" to refreshpdf
More information about the MacOSX-TeX