aboutsummaryrefslogtreecommitdiff
path: root/tex/src/preamble-pgfplots.tex
diff options
context:
space:
mode:
authorMohammad Akhlaghi <mohammad@akhlaghi.org>2019-02-06 02:45:41 +0000
committerMohammad Akhlaghi <mohammad@akhlaghi.org>2019-02-06 02:45:41 +0000
commit33e00f02d4ecd28ea5084fc553d2ad182a11ca52 (patch)
tree5505e4badcf844cfe9f3f12b2817db737053811c /tex/src/preamble-pgfplots.tex
parente19c7d38f00fe3612a8c499f8ac4c965f52cb86b (diff)
Better management for .tex directories to build from tarball
In order to collaborate effectively in the project, even project members that don't necessarily want (or have the capacity) to do the whole analysis must be able to contribute to the project. Until now, the users of the distributed tarball could only modify the text and not the figures (built with PGFPlots) of the paper. With this commit, the management of TeX source files in the pipeline was slightly modified to allow this as cleanly as I could think of now! In short, the hand-written TeX files are now kept in `tex/src' and for the pipeline's generated TeX files (in particular the old `tex/pipeline.tex'), we now have a `tex/pipeline' symbolic-link/directory that points to the `tex' directory under the build directory. When packaging the project, `tex/pipeline' will be a full directory with a copy of all the necessary files. Therefore as far as LaTeX is concerned, having a build-directory is no longer relevant. Many other small changes were made to do this job cleanly which will just make this commit message too long! Also, the old `tarball' and `zip' targets are now `dist' and `dist-zip' (as in the standard GNU Build system).
Diffstat (limited to 'tex/src/preamble-pgfplots.tex')
-rw-r--r--tex/src/preamble-pgfplots.tex107
1 files changed, 107 insertions, 0 deletions
diff --git a/tex/src/preamble-pgfplots.tex b/tex/src/preamble-pgfplots.tex
new file mode 100644
index 0000000..4999656
--- /dev/null
+++ b/tex/src/preamble-pgfplots.tex
@@ -0,0 +1,107 @@
+%% PGFPlots settings
+%% -----------------
+%%
+%% PGFPLOTS is a package in (La)TeX for making plots internally. It fits
+%% nicely with the purpose of a reproduction pipeline. But it isn't
+%% mandatory. Therefore if you don't need it, just comment/delete the line
+%% that includes this file in the top LaTeX source (`paper.tex').
+%%
+%% However, TiKZ and PGFPlots are the recommended way to include figures
+%% and plots in your paper. There are two main reasons: 1) it follows the
+%% same LaTeX settings as the text of the paper, so the figures will be in
+%% the exact same settings (for example font or lines) as the main body of
+%% the papers. 2) It doesn't require any extra dependency (it is
+%% distributed as part of TeX-live). Adding specific programs/libraries for
+%% plots can greatly increase the number of dependencies for the
+%% pipeline. For example Python's Matplotlib library is indeed very good,
+%% but it requires Python and Numpy. The latter is not easy to build from
+%% source, so after a few years, installing the required version can be
+%% very frustrating.
+%%
+%% Keeping all BibLaTeX settings in a separate preamble was done in the
+%% spirit of modularity to 1) easily managable, 2) If a similar BibLaTeX
+%% configuration is necessary in another LaTeX compilation, this file can
+%% just be copied there and used.
+%%
+%% PGFPlots uses the (La)TeX TiKZ package to build plots. So we will first
+%% do the settings that are necessary in TiKZ, and then go onto the actual
+%% PGFPlots package.
+%%
+%% USAGE:
+%%
+%% - All plots are made within a `tikz' directory (that must already be
+%% present in the location LaTeX is run).
+%%
+%% - Use `\includetikz{XXXX}' to make/use the figure. If a `makepdf' LaTeX
+%% macro is not defined, then \includetikz will assume a `XXXX.pdf' file
+%% exists in `tex/tikz' and simply import it. If `makepdf' is defined,
+%% then TiKZ/PGFPlot will be called to (possibly) build the plot based
+%% on `tex/XXXX.tex'. Note that if the contents of `tex/src/XXXX.tex'
+%% hasn't changed since the last build. TiKZ/PGFPlots won't rebuild the
+%% plot.
+
+
+
+
+
+%% Very general TiKZ settings. In particular, to allow faster processing
+%% (not having to re-build the plots on every run), we are using the
+%% externalization feature of TiKZ. With this option, TiKZ will build every
+%% figure independently in a special directory afterwards it will include
+%% the built figure in the final file. This has many advantages: 1) if the
+%% code for the plot hasn't changed, then the plot won't be re-made (can be
+%% slow with detailed plots). 2) You can use the PDFs of the individual
+%% plots for other purposes (for example to include in slides) cleanly.
+\usepackage{tikz}
+\usetikzlibrary{external}
+\tikzexternalize
+\tikzsetexternalprefix{tikz/}
+
+
+
+
+
+%% The following rule will cause the name of the files keeping a figure's
+%% external PDF to be set based on the file that the TiKZ commands are
+%% from. Without this, TiKZ will use numbers based on the order of
+%% figures. These numbers can be hard to manage and they will also depend
+%% on order in the final PDF, so it will be very buggy to manage them.
+\newcommand{\includetikz}[1]{%
+ \ifdefined\makepdf%
+ \tikzsetnextfilename{#1}%
+ \input{tex/src/#1.tex}%
+ \else
+ \includegraphics[width=\linewidth]{tex/tikz/#1.pdf}
+ \fi
+}
+
+
+
+
+
+%% Uncomment the following lines for EPS and PS images. Note that you still
+%% have to use the `pdflatex' executable and also add a `[dvips]' option to
+%% graphicx.
+
+%% \tikzset{external/system call={rm -f "\image".eps "\image".ps
+%% "\image".dvi; latex \tikzexternalcheckshellescape -halt-on-error
+%% -interaction=batchmode -jobname "\image" "\texsource";
+%% dvips -o "\image".ps "\image".dvi;
+%% ps2eps "\image.ps"}}
+
+
+
+
+
+%% Inport and configure PGFPlots.
+\usepackage{pgfplots}
+\pgfplotsset{compat=newest}
+\usepgfplotslibrary{groupplots}
+\pgfplotsset{
+ axis line style={thick},
+ tick style={semithick},
+ tick label style = {font=\footnotesize},
+ every axis label = {font=\footnotesize},
+ legend style = {font=\footnotesize},
+ label style = {font=\footnotesize}
+ }