[OS X TeX] Can a TeXShop engine give the PDF name?

Duncan Murdoch murdoch.duncan at gmail.com
Tue Dec 3 19:07:37 EST 2013


On 13-12-03 6:51 PM, Chris Goedde wrote:
> 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.
>
> Chris
>
> -----
> #!/bin/tcsh
>
> osascript << EOF
> tell application "TeXShop"
> open posix file "$cwd/foo.pdf"
> activate
> set index of window "$1:foo.pdf" to 1
> tell document "$1:foo.pdf" to refreshpdf
> end tell
> EOF

Thanks.  I'm very new (today!) to Applescript, so mine was simpler, just 
an "open", and not even a posix filename.  But your warnings about 
flakiness make me worry.

What I've currently got in place is simply to require the user to have a 
root file that my engine can handle to find all the subordinate files. 
If each chapter has "%!TEX root = Book.Rnw" and that file knows about 
the chapters, it works fine for me.

Duncan Murdoch



More information about the MacOSX-TeX mailing list