How it Started
I have been writing latex documents for a few years now. I stated with Overleaf, as it was incredibly easy to get started with. It also has a really nice interface for tracking errors, and you don’t have to worry about installing tex-packages. This would be perfect if it wasn’t for the fact that Overleaf runs in the browser, and is completely cloud based. I absolutely loathe this. After writing one major document in overleaf, i decided to make a local latex setup.
My first setup was quite simple. I simply bound a key in my editor to run the following command:
For this to work, my editor would have to be open in the root of my latex project which was sometimes a mild inconvenience. Still i used this approach for quite a while. At some point i swapped out pdflatex for latexmk, as i found i slightly nicer.
One thing i thought about then, was that some kind of template system would be nice. I spent some time developing one that used a mix of bash and python, but it sucked as it was needlessly complicated.
Procrastination is Great for Personal Projects!
During exams last month i stated this developing project. It was a simple act of procrastination. I decided to write it in python as that was what i knew best. I also found the click package that made it pretty simple to create a cli application.
Problems and Solutions
These were the main goals of the program:
- Make a compile command that also works in subdirectories of the project
- Make a template system that is easy to use and simple to add templates to
The Compile Command
To make the compile command work in subdirectories, there had to be a way to know where the root of the document file structure was. For this i needed some kind of anchor point. Just like git has a
.git folder in the root directory of every repository, i wanted to have a file called
.blatex at the root of the latex project. This way i would always be able to find the root by just going up folders until i found the
.blatex file. Another great thing about having this file, was that i now had a place to store a local project configuration.
The Template System
As i had tried and failed to make a complicated latex template system already, i now wanted to make something simple and foolproof. The solution i came up with was plane old zip files. One template, one zip file. These zip files would simply contain all the files in the template. Because of this, blatex just became a glorified zip extractor, but that was the exact simplicity i was going for.