I'm trying to create a script that compiles LaTeX on OS X. Unfortunately I'm not familiar with the language and even though the code works, it has several flaws. Is it possible to close the terminal without having to kill it (and every other instance of it)? Can it be improved easily to automatically find and compile all .tex-files in the folder?
#!/bin/bash
STR="document"
BASEDIR="$( dirname "$0" )"
cd "$BASEDIR"
pdflatex $STR.tex
bibtex $STR.aux
pdflatex $STR.tex
pdflatex $STR.tex
rm $STR.ilg
rm $STR.toc
rm $STR.aux
rm $STR.out
open $STR.pdf
killall Terminal
latexmk- you need to look at timestamps to do this well. Further to what @egreg said, removing auxiliary files that are more than a week old is usually OK, but that's best done by a housekeeping program, not a compile script. – Charles Stewart Feb 19 '13 at 14:07.auxfile is used for many things including cross-referencing, citations, language data (if you are usingbabel) and stores information that is then read back in on subsequentlatexandbibtexcompilations. So if you delete them immediately after your first compilation your document will not be complete. – Alan Munn Feb 19 '13 at 16:05latexrun or multiplelatex-bibtexruns every time. On a short document that might not be a big deal, but it can become pretty annoying very fast on a larger document. – Ricardo Feb 19 '13 at 18:15latexit does a few passes to figure out how to layout the paragraphs and pages optimally; it also makes note of any cross-reference (citations, tables of contents, etc.) and translations, and creates appropriate files for those if they don't already exist. If the files exist, it verifies that their information is consistent with the source. If it is, it outputs, if not, it overwrites them and requests for you to runlatexagain. See http://tex.stackexchange.com/a/53236/3731. – Ricardo Feb 19 '13 at 18:39