This repository contains an example of project code for automatic dependencies management and perfect integration of results in LaTeX. The goals are twofolds:
- Automating the build, from raw data to final document.
- Getting rid of the tedious process of manually regenerating results, figures, tables when they get outdated.
In a typical project, the general workflow is given by the following chart.
- A numerical experiment is set up based on some input data (e.g. training dataset, experimental measurements etc.) and configuration files (e.g. hyperparameters).
- Scripts produce intermediate files (e.g. checkpoints etc.) that can be used by other scripts. Final figures and tables are also scripted for reproducibility and automatic management purposes.
- The final document is produced using LaTeX.
Ideally, the whole pipeline should have the following properties:
- Scripted management: Every arrow in the chart should be automated and a modification somewhere in the pipeline should trigger the built of all dependencies. This allows consistency and minimum human intervention in case of modifications in the pipeline.
- Integration: The style of the final artifacts (figures, tables etc.) should match exactly the style of the document (font, sizes etc.)
This project is an attempt to obtain such properties. It relies on Makefiles to manage and build dependencies and on the PythonTeX package to call Python within LaTeX.
-
Clone the project
git clone --recurse-submodules https://github.com/bilelomrani1/latex-workspace.git cd latex-workspace
-
Create a new virtual environment (recommended), for example with conda
conda create -n latex python=3.8 conda activate latex
-
Set your environment variables
conda env config vars set MATPLOTLIBRC=$(cd report; pwd) conda env config vars set TEXINPUTS=.:$(cd report; pwd):$TEXINPUTS conda env config vars set PATH=$PATH:$(cd report; pwd) conda activate latex
-
Install dependencies
pip install -r requirements.txt
-
Install the custom pygments color scheme
cd report/pygments-style-workspace sudo python setup.py install
-
Follow the instructions on Latexmk website to install
latexmk
.
Use the Makefile to manage dependencies and set up the pipeline. In the report/
directory, use make
to automatically build the PDF report. Additionally, you can use the following recipes:
make draft
to create a draft version of the reportmake revision
to create a revision versionmake print
to create a printable version of the reportmake clean
to clean auxiliary filesmake cleanall
to clean more aggressively.
To create a new subfile directory, run the following command in the tex/
directory
cookiecutter new_subfile/
A subfile can be compiled separately with its own Makefile.
The minionpro
option of the class file workspace.cls
requires a valid installation of Adobe MinionPro font, along with LaTeX package minionpro
.