aboutsummaryrefslogtreecommitdiff
path: root/reproduce/analysis/make/paper.mk
diff options
context:
space:
mode:
Diffstat (limited to 'reproduce/analysis/make/paper.mk')
-rw-r--r--reproduce/analysis/make/paper.mk51
1 files changed, 43 insertions, 8 deletions
diff --git a/reproduce/analysis/make/paper.mk b/reproduce/analysis/make/paper.mk
index 906b4d9..f363b6f 100644
--- a/reproduce/analysis/make/paper.mk
+++ b/reproduce/analysis/make/paper.mk
@@ -44,7 +44,7 @@ $(mtexdir)/project.tex: $(mtexdir)/verify.tex
# If no PDF is requested, or if LaTeX isn't available, don't
# continue to building the final PDF. Otherwise, merge all the TeX
# macros into one for building the PDF.
- @if [ -f .local/bin/pdflatex ] && [ x"$(pdf-build-final)" != x ]; then
+ @if [ -f .local/bin/latex ] && [ x"$(pdf-build-final)" != x ]; then
# Put a LaTeX input command for all the necessary macro files.
# 'hardware-parameters.tex' is created in 'configure.sh'.
@@ -87,18 +87,32 @@ $(mtexdir)/project.tex: $(mtexdir)/verify.tex
#
# NOTE: `$(mtexdir)/project.tex' is an order-only-prerequisite for
# `paper.bbl'. This is because we need to run LaTeX in both the `paper.bbl'
-# recipe and the `paper.pdf' recipe. But if `tex/src/references.tex' hasn't
+# recipe and the `paper.pdf' recipe. But if `tex/src/references.bib' hasn't
# been modified, we don't want to re-build the bibliography, only the final
# PDF.
$(texbdir)/paper.bbl: tex/src/references.tex $(mtexdir)/dependencies-bib.tex \
| $(mtexdir)/project.tex
+
# If `$(mtexdir)/project.tex' is empty, don't build PDF.
@macros=$$(cat $(mtexdir)/project.tex)
if [ x"$$macros" != x ]; then
+ # Unfortunately I can't get bibtex to look into a special
+ # directory for the references, so we'll copy it into the LaTeX
+ # building directory.
+ p=$$(pwd)
+ if ! [ -L $(texbdir)/references.bib ]; then
+ ln -s $$p/tex/src/references.tex $(texbdir)/references.bib
+ fi
+
+ # Copy the improved IEEE bst file into the build directory.
+ # The improved bst file provides ArXiv clickable URLs and
+ # if available, open-access URLs based on the DOIs, with
+ # closed-access URLs as a fallback, via https://oadoi.org .
+ cp -pv $$p/tex/src/IEEEtran_openaccess.bst $(texbdir)
+
# We'll run LaTeX first to generate the `.bcf' file (necessary
# for `biber') and then run `biber' to generate the `.bbl' file.
- p=$$(pwd)
export TEXINPUTS=$$p:
cd $(texbdir);
@@ -114,9 +128,23 @@ $(texbdir)/paper.bbl: tex/src/references.tex $(mtexdir)/dependencies-bib.tex \
# do not use PGFPlots, then you should remove the `-shell-escape'
# option for better security. See
# https://savannah.nongnu.org/task/?15694 for details.
- pdflatex -shell-escape -halt-on-error "$$p"/paper.tex
- biber paper
-
+ latex -shell-escape -halt-on-error "$$p"/paper.tex
+ bibtex paper
+
+ # Hack: tidy up eprint+doi style that didn't work in .bst file.
+ # TODO (better): read Part 4 of
+ # http://mirrors.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf
+ # and fix the .bst style properly.
+ cp paper.bbl paper-tmp.bbl \
+ && sed -e "s/\'/EOLINE/g" paper-tmp.bbl \
+ | tr -d '\n' \
+ | sed -e 's/\([0-9]\)\( \|EOLINE\)}/\1}/g' \
+ | sed -e 's/\([^,]\) *\( \|EOLINE\) *\\eprint/\1, \\eprint/g' \
+ | sed -e 's/\([^,]\) *\( \|EOLINE\) *\\doi/\1, \\doi/g' \
+ | sed -e 's/EOLINE/\n/g' > paper.bbl
+
+ # The pre-final run of LaTeX after 'paper.bbl' was created.
+ latex -shell-escape -halt-on-error "$$p"/paper.tex
fi
@@ -141,13 +169,20 @@ paper.pdf: $(mtexdir)/project.tex paper.tex $(texbdir)/paper.bbl
p=$$(pwd)
export TEXINPUTS=$$p:
cd $(texbdir)
+
# See above for a warning and brief discussion on the the
# pdflatex option `-shell-escape'.
- pdflatex -shell-escape -halt-on-error "$$p"/paper.tex
+ latex -shell-escape -halt-on-error "$$p"/paper.tex
+
+ # Convert the DVI to PostScript, and the PostScript to PDF. The
+ # `-dNOSAFER' option to GhostScript allows transparencies in the
+ # conversion from PostScript to PDF, see
+ # https://www.ghostscript.com/doc/current/Language.htm#Transparency
+ dvips paper.dvi
+ ps2pdf -dNOSAFER paper.ps
# Come back to the top project directory and copy the built PDF
# file here.
cd "$$p"
cp $(texbdir)/$@ $(final-paper)
-
fi