I'm trying to make a function that compiles my latex documents from the command line. My problem is that the references never show up on the first run so I usually end up running this function twice... it's usually not a big deal unless I'm working on a large document.
Anyone know why the references might not be showing up first time through?
I based my function off what I think TexMaker is doing: Options/Configure TexMaker/Quick Build
PdfLaTeX + Bib(la)tex + PdfLaTeX (x2) + View Pdf
any thoughts?
generatePDF() {
GREEN='\033[1;32m'
NC='\033[0m' # No color
echo -e "${GREEN}Running pdflatex ${NC}"
pdflatex -synctex=1 -interaction=nonstopmode -enable-write18 -shell-escape $1.tex
# TODO: needs more error testing for next commands...
echo -e "${GREEN}Running bib(la)tex...${NC}"
bibtex $1.aux
echo -e "${GREEN}Running pdflatex again...${NC}"
pdflatex -synctex=1 -interaction=nonstopmode -enable-write18 -shell-escape $1.tex
echo -e "${GREEN}Opening pdf... ${NC}"
gnome-open $1.pdf
}
cleanPDFdir() {
GREEN='\033[1;32m'
NC='\033[0m' # No color
echo -e "${GREEN}Removing auxiliary files...${NC}"
rm -v $1.pdf
rm -v $1.aux
rm -v $1.bbl
rm -v $1.bbg
rm -v $1.log
rm -v $1.synctex*
}
alias pdfmake='generatePDF'
alias pdfclean='cleanPDFdir'
I run the function by just specifying the main file's name without the extension:
pdfmake my_tex_file
additional info from comments: I'm using emacs so started putting this script together so I could quickly compile like I did when using TexMaker's quick build.
The individual commands I just found here and on Stack Overflow so I don't really understand what each is doing.
.bib
or\ref
- like) always need two runs. I suggest to use aMakefile
and ordinarymake
. You should also mention that this a shell-script?.tex
file witharara
might also be a possibility. (texdoc arara
or go to texdoc.net and search forarara
.)make
or latexmk or ...