---
title: Taking notes with Markdown and LaTeX
description: Using a lot of tech to replace a piece of paper
date: 2020-08-23
tags:
  - pandoc
  - latex
  - bazel
  - school
extra:
  excerpt: I have completely reworked my school notetaking system to use LaTeX.  This post outlines how I did everything, and my new workflow.
redirect_from:
  - /post/68df02l4/
  - /68df02l4/
aliases:
  - /blog/2020/08/23/notetaking-with-latex
  - /blog/notetaking-with-latex
---

*You can view my public demo for this post [here](https://github.com/Ewpratten/school-notes-demo)*

Recently, I have been on a bit of a mission to improve my school workflow with software. Over the past month, I have built a cleaner [student portal](https://github.com/Ewpratten/student_portal#unofficial-tvdsb-student-portal-webapp) for my school and [written a tool](https://github.com/Ewpratten/timeandplace-api#timeandplace-api--cli-application) for automating in-class attendance. Alongside working on these projects, I have also been refining my notetaking system for school.

Since 9th grade, I have been taking notes in a private GitHub repository in markdown, and have been compiling them to HTML using a makefile for each course. While this system has worked ok, It has been far from perfect. Recently, I have been working very hard to give this system a much-needed upgrade. Here is the new tech stack:

 - The [Bazel buildsystem](https://bazel.build)
 - [Markdown](https://en.wikipedia.org/wiki/Markdown)
 - [LaTeX](https://en.wikipedia.org/wiki/LaTeX)
 - [MathJax](https://www.mathjax.org/)
 - [Beamer](https://ctan.org/pkg/beamer)
 - [Tikz & PGF](https://ctan.org/pkg/pgf)
 - [Pandoc](https://pandoc.org/)
 - [Zathura](https://pwmt.org/projects/zathura/)
 - [Starlark](https://docs.bazel.build/versions/master/skylark/language.html)
 - [Github Actions](https://github.com/features/actions) CI

The idea is that every course I take becomes its own Bazel package, with subpackages for things like assignments, papers, notes, and presentations. I can compile everything just by running the command `bazel build //:all`. All builds are cached using Bazel's build caching system, so when I run the command to compile my notes (I love saying that), I only end up compiling things that have changed since the last run. The setup for all of this is quite simple. All that is really needed is a Bazel workspace with the [`bazel_pandoc`](https://github.com/ProdriveTechnologies/bazel-pandoc) rules loaded (although I have opted to use some custom [genrules](https://docs.bazel.build/versions/master/be/general.html#genrule) instead). Using these rules, markdown files can be concatenated, and compiled into a PDF. I also use a modified version of the [Eisvogel](https://github.com/Wandmalfarbe/pandoc-latex-template) Pandoc template to make all my documents look a little neater.

In terms of workflow, I write all my notes as markdown files with [embedded LaTeX](https://pandoc.org/MANUAL.html#math) for any equations and charts I may need. All of this is done inside of VSCode, and I have a custom `tasks.json` file that lets me press <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>b</kbd> to re-compile whatever I am currently working on. I also keep Zathura open in a window to the side for a nearly-live preview system.

<script src="https://gist.github.com/Ewpratten/163aa9c9cb4e8c20e732e3713c95c915.js" ></script>

![](/images/posts/latex-notes/hs_notes_workflow.png)
*A screenshot of my workspace*

Now, the question came up of *"how do you easily distribute notes and assignments to classmates and professors?"*. That question got me stuck for a while, but here is the system I have come up with:

 1. I write an assignment
 2. I push it to the private GitHub repository
 3. GitHub Actions picks up the deployment with a custom build script
 4. Every document is built into a PDF, and packaged with a directory listing generated by [`tree -H`](http://mama.indstate.edu/users/ice/tree/tree.1.html#XML/JSON/HTML%20OPTIONS)
 5. Everything is pushed to a subdomain on my website via GitHub pages
 6. I can share documents via URL to anyone

This is almost entirely accomplished by a shell script and a custom CI script.

<script src="https://gist.github.com/Ewpratten/4a69af01250291eb2981510feddef642.js"></script>

---

If you have any questions about this system, want me to write another post about it, or would like me to walk you through setting up a notes workspace of your own, [contact me](/contact)