diff --git a/chapter.mk b/chapter.mk index cd6fe56..ec6fe68 100644 --- a/chapter.mk +++ b/chapter.mk @@ -34,8 +34,8 @@ chapter : $(BASENAME)-chapter.pdf $(BASENAME)-chapter.pdf : $(BASENAME)-chapter.tex $(BASENAME).tex $(wildcard $(BASENAME).aux) $(PYPDFFILES) $(GPTTEXFILES) ../../header.tex if test -f $(BASENAME).aux; then \ - CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p}' $(BASENAME).aux) - 1 )); \ - PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p}' $(BASENAME).aux); \ + CHAPTER=$$(( $$(sed -n -e '/contentsline {chapter}/{s/.*numberline {\([0123456789]*\)}.*/\1/; p; q}' $(BASENAME).aux) - 1 )); \ + PAGE=$$(sed -n -e '/contentsline {chapter}/{s/.*numberline {.*}.*}{\(.*\)}{chapter.*/\1/; p; q}' $(BASENAME).aux); \ fi; \ { echo $${PAGE:=1}; echo $${CHAPTER:=0}; } | pdflatex -interaction=scrollmode $< | tee /dev/stderr | fgrep -q "Rerun to get cross-references right" && { echo $${PAGE:=1}; echo $${CHAPTER:=0}; } | pdflatex -interaction=scrollmode $< || true