Skip to content

Instantly share code, notes, and snippets.

@ianhomer
Last active June 15, 2025 18:37
Show Gist options
  • Save ianhomer/aa3b19ec14bc4853c2e5c49ad3091d81 to your computer and use it in GitHub Desktop.
Save ianhomer/aa3b19ec14bc4853c2e5c49ad3091d81 to your computer and use it in GitHub Desktop.
Rebuild Latex file on change and refresh PDF preview

Rebuild Latex file on change and refresh PDF preview

Scripts that rebuild a Latex file and refresh PDF preview on a Mac. Allows edit of tex file to refresh in PDF to see live rendering.

Open Script Editor and create script called refresh-preview.scpt

tell application "Preview" to activate
tell application "WezTerm" to activate

Edit the Makefile to specify the tex file your editing.

Run the following in a terminal to get live rendering of your latex document.

./watch
preview: my.pdf
my.pdf: my.tex
@echo "Reloading ..."
@pdflatex my.tex >/dev/null
@open my.pdf
@osascript refresh-preview.scpt
#!/usr/bin/env bash
make --always-make preview
fswatch -o ./*.tex | xargs -n1 -I{} make preview
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment