Posts tagged ‘preview’

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 build.sh

#!/bin/bash

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

for i in `ls *.tex`; do
    echo
    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\.'
done

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

#!/bin/bash
while inotifywait -e close_write *.tex;
do
    ./build.sh;
done

Have fun.