From 30733df5d30e150a26d53173d14bf941f179f6f5 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Tue, 27 Feb 2018 14:48:02 +0100 Subject: Default PDF now uses PGFPlots and BibLaTeX Making plots and including references are integral parts of a scientific paper. Therefore to demonstrate how cleanly they can be used within the pipeline, they are now used to produce the final PDF. To use PGFPlots a random dataset is made (using AWK's random function) and is plotted using PGFPlots. The minimum and maximum values of the dataset are also included in the text to further show how such calculations can go into the macros and text. For the references, the NoiseChisel paper was added as a reference to cite when using this pipeline along with the MUSE UDF paper I, which uses this pipeline for two sections. Following this discussion, citation is also discussed in `README.md` and the NoiseChisel paper is also added as a published work with a reproduction pipeline. --- reproduce/src/make/delete-me.mk | 73 ++++++++++++++++++++++++++++++++++++++++ reproduce/src/make/initialize.mk | 6 ++-- reproduce/src/make/paper.mk | 33 +++++++++++++++--- 3 files changed, 105 insertions(+), 7 deletions(-) create mode 100644 reproduce/src/make/delete-me.mk (limited to 'reproduce/src') diff --git a/reproduce/src/make/delete-me.mk b/reproduce/src/make/delete-me.mk new file mode 100644 index 0000000..a93c2d0 --- /dev/null +++ b/reproduce/src/make/delete-me.mk @@ -0,0 +1,73 @@ +# Dummy Makefile to create a random dataset for plotting. +# +# Original author: +# Mohammad Akhlaghi +# Contributing author(s): +# Copyright (C) 2018, Your Name. +# +# This Makefile is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This Makefile is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# A copy of the GNU General Public License is available at +# . + + + + + +# Dummy dataset +# ------------- +# +# We will use AWK's random number generator to generate a random dataset to +# be imported by PGFPlots for a plot in the paper. +dmdir = $(texdir)/delete-me +dm = $(dmdir)/data.txt +$(dmdir): | $(texdir); mkdir $@ +$(dm): $(pconfdir)/delete-me-num.mk | $(dmdir) + + # When the plotted values are re-made, it is necessary to also + # delete the TiKZ externalized files so the plot is also re-made. + rm -f $(tikzdir)/delete-me.pdf + + # Generate the table of random values. + awk 'BEGIN { for (i = 1; i <= $(delete-me-num); i++) \ + print i, rand(); }' > $@ + + + + + +# TeX macros +# ---------- +# +# This is how we write the necessary parameters in the final PDF. +# +# NOTE: In LaTeX you cannot use any non-alphabetic character in a variable +# name. +$(mtexdir)/delete-me.tex: $(dm) + + # Write the number of random values used. + echo "\newcommand{\deletemenum}{$(delete-me-num)}" > $@ + + # Note that since Make variables start with a `$(', if you want to + # use `$' within the shell (not Make), you have to quote any + # occurance of `$' with another `$'. That is why there are `$$' in + # the AWK command below. + # + # Here, we are first using AWK to find the minimum and maximum + # values, then using it again to read each separately to use in the + # macro definition. + mm=$$(awk 'BEGIN{min=99999; max=-min} \ + {if($$2>max) max=$$2; if($$2> $@; \ + v=$$(echo "$$mm" | awk '{printf "%.3f", $$2}'); \ + echo "\newcommand{\deletememax}{$$v}" >> $@ diff --git a/reproduce/src/make/initialize.mk b/reproduce/src/make/initialize.mk index 70d77ed..4f134a9 100644 --- a/reproduce/src/make/initialize.mk +++ b/reproduce/src/make/initialize.mk @@ -37,6 +37,8 @@ texdir = $(BDIR)/tex srcdir = reproduce/src lockdir = $(BDIR)/locks +texbdir = $(texdir)/build +tikzdir = $(texbdir)/tikz mtexdir = $(texdir)/macros gconfdir = reproduce/config/gnuastro pconfdir = reproduce/config/pipeline @@ -100,10 +102,10 @@ $(pconfdir)/LOCAL.mk: # option: they add too many extra checks that make it hard to find what you # are looking for in this pipeline. .SUFFIXES: -$(mtexdir): | $(texdir); mkdir $@ +$(tikzdir): | $(texbdir); mkdir $@ $(BDIR): | $(pconfdir)/LOCAL.mk; mkdir $@ $(texdir) $(lockdir): | $(BDIR); mkdir $@ - +$(mtexdir) $(texbdir): | $(texdir); mkdir $@ diff --git a/reproduce/src/make/paper.mk b/reproduce/src/make/paper.mk index db20279..f3db1de 100644 --- a/reproduce/src/make/paper.mk +++ b/reproduce/src/make/paper.mk @@ -22,16 +22,39 @@ +# The bibliography +# ---------------- +# +# We need to run the `biber' program on the output of LaTeX to generate the +# necessary bibliography before making the final paper. +# +# NOTE: `tex/pipeline.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/references.tex' hasn't +# been modified, we don't want to re-build the bibliography, only the final +# PDF. +$(texbdir)/paper.bbl: tex/references.tex \ + | $(tikzdir) $(texbdir) tex/pipeline.tex + + # 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:$$TEXINPUTS; \ + cd $(texbdir); \ + pdflatex -shell-escape -halt-on-error $$p/paper.tex; \ + biber paper + + + + + # The final paper # --------------- # # The commands to build the final report. We want the pipeline version to # be checked everytime the final PDF is to be built. -texbdir=$(texdir)/build -tikzdir=$(texbdir)/tikz -$(texbdir): | $(texdir); mkdir $@ -$(tikzdir): | $(texbdir); mkdir $@ -paper.pdf: tex/pipeline.tex paper.tex | $(tikzdir) $(texbdir) +paper.pdf: tex/pipeline.tex paper.tex $(texbdir)/paper.bbl \ + | $(tikzdir) $(texbdir) # Make the report. p=$$(pwd); \ -- cgit v1.2.1