Continuously build / preview a latex document

You can easily build and preview latex documents using both emacs and evince. Evince will reload pdf documents once changed. I use inotify to trigger the build shell script once any .tex file is changed. The scripts below are generic enough to be used for any build:

The first script is


pdfcmd="pdflatex -file-line-error -interaction batchmode"

for i in `ls *.tex`; do
    echo Building $i
    echo '***************************'
    ${pdfcmd} $i
    basename=`basename $i tex`
    echo Basename is ${basename}
    bibtex ${basename}aux
    ${pdfcmd} $i
    ${pdfcmd} $i

    cat ${basename}log | grep 'l\.'

The second script checks for any modified .tex file, then re-invokes

while inotifywait -e close_write *.tex;

Have fun.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.