Home > python > autocompile LaTeX project when a file changes

autocompile LaTeX project when a file changes

Problem
When I work with LaTeX, I always create a script called “compile.sh” that compiles the project and produces a PDF. For viewing the PDF file I use okular since it refreshes automatically if the PDF changes. However, if I change the LaTeX source, I need to call the “compile.sh” script manually. Could it be automated? That is, when I save the LaTeX source, the project should compile automatically, so I should only switch between my text editor and the PDF viewer.

Solution
I found a complete solution for the problem: autocompile.py. It’s a demo script that is part of the pyinotify project.

Usage:

./autocompile.py . .tex,.bib ./compile.sh

I put autocompile.py in the root folder of the LaTeX project, next to the compile.sh script. The command above means the following: “monitor the current directory recursively. When a .tex or .bib file changes, call the compile.sh script.”

Related

Advertisements
Categories: python Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: