UPDATE 3: I have updated the script to support command-line options that will prevent TeXShop from doing things like refreshing text (and trashing your unsaved changes), activating (taking your focus away), and opening (possibly getting in front of your view). Try the -h option for details.
UPDATE 2: There is a related Skim revision that will make it easier to use AppleScript for PDFSync interfacing. This change will prevent having to make UNIX shell scripts that must be modified with chmod.
UPDATE 1: As you can see in the Skim revision history, future versions of Skim will include their "Application Support" directory (e.g., ~/Library/Application Support/Skim/) as well as a "Scripts" subdirectory in their path. When that occurs, scripts like the one below can be stored there and executed from Skim without specifying the full path name.
I know there are ways to change TeXShop's previewer; however, I don't know how to do them. Additionally, I don't use TeXShop, so I have little incentive to look those things up.
However, I do use Skim, which is compatible with pdfsync, and recently someone asked me how they could get Skim to call up TeXShop at a particular line (as someone would want to do when using pdfsync).
For that, I generated a texshop script that looks like this (an earlier version of this can be found on the Skim wiki):
To use this script, follow these steps:fileName="$1"
lineNumber="$2"
gotoString=""
[ "${fileName:0:1}" == "/" ] || fileName="${PWD}/${fileName}"
[ "${lineNumber}" == "" ] || gotoString="goto line ${lineNumber}"
exec osascript \
-e "set texFile to POSIX file \"${fileName}\"" \
-e "tell application \"TeXShop\"" \
-e "activate" \
-e "open texFile" \
-e "tell front document" \
-e "refreshtext" \
-e "${gotoString}" \
-e "end tell" \
-e "end tell"
- Save that file as something (preferably in the PATH somewhere, but this is not necessary) like
/usr/local/bin/texshop
or anywhere you would like (e.g., /Users/username/bin/texshop). However, if you place it somewhere differently, be sure to update the red text in these instructions. - Next, chmod it 0755, as in
chmod 0755 /usr/local/bin/texshop
This can be done from the Terminal. - Finally, tell Skim's PDFSync preferences (under Preferences->LaTeX or Preferences->Sync depending on your Skim version) to use a "Custom" editor with
Command: /usr/local/bin/texshop
Make sure you click AWAY (e.g., onto a different tab) from the PDFSync settings before you close the Preferences. Otherwise, one of your text boxes may not get saved.
Arguments: "%file" %line
Note that if you have saved texshop somewhere in your PATH, then you should be able to drop the /usr/local/bin/ from the front of the Command: line.
2 comments:
Some great work here. The only issue I had was when I wrote 'texshop' in Command: texshop, doing Shift+Command+CLICK in Skim on a location in the PDF didn't bring up the source in TeXShop. It only worked when I put the full path "/usr/local/bin/texshop" for the script, as in Command: /usr/local/bin/texshop
That's because /usr/local/bin must not be in your path. It is in mine, so it works fine just with "texshop".
Because multiple people have told me that the full path works fine, I'll change the instructions to give an explicit path.
Post a Comment