Hello! Welcome to another installment of “How to get math software working in the Windows Subsystem for Linux”. Last time I set up Lean4 in Emacs using Debian, but this time we’re branching off into using a project called PreTeXt.
PreTeXt is basically a system designed explicitly for authoring math papers and textbooks using a formatting language called “LaTeX”. The official documentation for PreTeXt recommends that you use the GitHub Workspace instead of WSL for new projects, but I already have an existing such repository where I had been working the exercises in Lawvere and Schanuel which you can find here: https://rruff82.github.io/LS-Categories/
The reason I’ve chosen to go with a WSL installation of PreTeXt is that it enables me to work locally and avoid hitting my compute-hour quota on GitHub. The downside is that there are a lot of prerequisite components that need to be installed for PreTeXt to work properly and the error messages aren’t necessarily that informative. Through trial and error, I determined I had to install the following packages on my Debian installation:
sudo apt install git
sudo apt install curl
sudo apt install texlive
sudo apt install texlive-xetex
sudo apt install xsltproc
sudo apt install pkg-config
sudo apt install cmake
sudo apt install libcairo2-dev
sudo apt install poppler-utils
sudo apt install python3
sudo apt install python3-pip
sudo apt install python3-venv
sudo apt install python3-cairo
Next, I set up a Python “Virtual Environment” to house subsequent packages in. This lets me to install packages locally without messing with the system-wide configuration:
python3 -m venv .venv
To activate our new virtual environment:source .venv/bin/activate
The bash prompt should now have a “(.venv)” at the start and we safely can install PreText:
pip3 install pretext[all]
You can check the installation with “pretext –version”. Mine responds with 2.39.0.
Unfortunately, we’re not quite done yet. It’ll run, but errors out for… ::gestures wildly:: “reasons”. It turns out that we also needed to install “node.js” and the “npm” package manager. I chose to to install these using the “nvm” method by following the instructions found at https://nodejs.org/en/download
# Download and install nvm: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash # in lieu of restarting the shell \. "$HOME/.nvm/nvm.sh" # Download and install Node.js: nvm install 24 # Verify the Node.js version: node -v # Should print "v24.15.0". # Verify npm version: npm -v # Should print "11.12.1".I used my own existing “code-space” repository as a test:
git clone https://github.com/rruff82/LS-Categories.git
cd LS-Categories/
pretext build web
pretext view web
If everything has gone well, this should give you a local mirror of my GitHub page in your web browser! Please excuse the warnings indicating that my stuff is wildly out of date. You should be able to use CTRL-c to terminate the server from the console when you’re done using it. In the long term, I’d like to be able to replicate the VSCode workflow in Emacs but that’s a problem for another day.
Anyway… hope this helps someone else out there! Good luck!