Replacing PDFView with Skim is something that I've been thinking about for a while, but it hasn't been a high priority. Happily, Al Kasprzyk provided a script to make that replacement in a comment to the earlier post. For convenience, I'll reproduce it here, with syntax highlighting:
cd "`dirname "$1"`"
latexmk -pdf -quiet "`basename "$1"`"
pdfName=$(basename "$1" tex)pdf
if test -s "$pdfName"; then
/Applications/Skim.app/Contents/SharedSupport/displayline $2 "$pdfName" "$1"
fi
latexmk -pdf -quiet "`basename "$1"`"
pdfName=$(basename "$1" tex)pdf
if test -s "$pdfName"; then
/Applications/Skim.app/Contents/SharedSupport/displayline $2 "$pdfName" "$1"
fi
Perhaps the greatest difference is that Al uses the
displayline
script included with Skim, instead of just opening the PDF created from the LaTeX document. Thus, instead of having latexmk
open the preview, he handles it himself. behaviorally, the preview is shown in Skim, with the current line selected in SEE being visible in Skim.We can rewrite my earlier script to take a similar approach. Without either following Al's script exactly or avoiding looking at it, I came up with this:
PATH=/usr/texbin:/usr/local/bin:$PATH
export PATH
cd "$(dirname "$1")"
latexmk -pdf -quiet "$(basename "$1")"
PRODUCT="$(basename "$1" .tex).pdf"
if [ -s "$PRODUCT" ]
then
open -a PDFView.app "$PRODUCT"
fi
export PATH
cd "$(dirname "$1")"
latexmk -pdf -quiet "$(basename "$1")"
PRODUCT="$(basename "$1" .tex).pdf"
if [ -s "$PRODUCT" ]
then
open -a PDFView.app "$PRODUCT"
fi
The differences between the two scripts are minor. Apart from some formatting choices, there are just a few differences. First, I set the
PATH
environment variable. I'm pretty sure Al must have done so as well, but he didn't include it in his comment. Second, I have an extra layer of quoting for what I called the PRODUCT
; based on restrictions for LaTeX file names, these are superfluous. Third is the obvious and essential difference of which viewer we call. Right now, there is no change in behavior between my earlier script and the one I present above. However, I no longer need to define anything in a
.latexmkrc
file, which is helpful in making a portable LaTeX mode. Better, though, is that the obvious parallels between Al's script and mine can be taken advantage of. Next time.
No comments:
Post a Comment