Thursday, July 12, 2007

Skim automatic refreshes and simpdftex

UPDATE: I've updated the script so that it works with OS/X Leopard. See comments for details.
The OS X PDF viewer Skim has the ability to automatically refresh files after they have been updated on disk. In Skim version 0.4.1 and below, this was done by polling a file every second to see if it has been changed. In Skim version 0.5 and up, this feature is implemented using kqueue events. This is a much better way of doing things. However, if the file that is open gets deleted and a new file created with the same name, events for that new file will not be received by Skim.

Unfortunately, the script simpdftex that comes with a number of LaTeX distributions (e.g., gwTeX) deletes a PDF before updating it. This means that autorefreshes won't work when regenerating a PDF from its LaTeX source using simpdftex.

So, motivated by the history in a Skim bug report, I've put together a simpdftexnodel script that fixes this problem (based on the 2007/05/07 gwTeX simpdftex). To use this file:
  • Place the script somewhere (probably in your PATH).
  • chmod the file 0755.
  • Make sure that your distillers and TeX program (or at least symlinks to them) exist in the same directory.
  • Stop using simpdftex and start using simpdftexnodel.
I hope that helps!


Enrico said...

It seems to me that it doesn't work anymore with Leopard since it skips the latex step:

Running `LaTeX' on `scholarship-letter-2-2008' with ``simpdftex-1 latex --mode dvips --maxpfb --distiller ps2pdf14 --tex-path /usr/texbin --extradvipsopts '-ta4' scholarship-letter-2-2008.tex''
### This is /usr/texbin/simpdftex-1, Version 20070712
### Skipping simpdftex-1 [dvi->pdf only]

Ted said...

Enrico, you *must* name the script "simpdftexnodel". You cannot name it something else. The script uses its name to give it information about how it's called.

Your problem has nothing to do with Leopard. You're having the problem because you called it "simpdftex-1".

Ted said...

It turns out the problem *does* have to do with Leopard.

Anyone with an old version of simpdftex(nodel) should change the top line from




The script uses several "bashisms" that are not available in standard "sh." Leopard makes "sh" the more pure form, and so it breaks scripts that call it and yet use bashisms.

Ted said...

I should mention that if you leave the


alone and instead change every

echo -n


printf "%s"

then your script will be MARGINALLY faster. /bin/bash has a bit more overhead than /bin/sh. Most people won't notice a difference.