Compile your LaTeX documents faster on Windows with Docker
I’m in a university in Japan and writing the doctoral thesis with LaTeX on my Windows laptop computer. It’s a stressful time for me to wait for compilation large files like dissertations to finish.
Recently, I noticed that this stressful situation is unique for Windows system. When I compiled the same document on my Linux desktop computer, the compile process was over in an instant. Of course, the machine power of desktop PC is stronger than laptop one (laptop: Core i7 10510U vs. desktop: Core i7 9700K), but the compile speed was amazingly different.
So, I compared the speed in the same computer, that is, Windows versus WSL. The result is,
Windows: 2 min 40 sec
WSL: 32 sec
5 times faster!!!
I introduce you how to speed up your LaTeX compile on Windows.
Environment
- Windows 10
- WSL2 (Ubuntu 20.04)
- Core i7 10510U
- 16 GB RAM
- Docker 20.10.10
The directory is like that.
.
├── Dockerfile
├── docs
│ ├── DoctralThesis.tex
│ ├── .latexmkrc
│ ├── chapters
│ ├── citations.bib
│ ├── mypack.sty
│ ├── report.bst
└── fig
├── ch01
├── ch02
└── ch03
I put my original style file, mypack.sty
, in the same directory with my document for the sake of simplicity.
Create Docker container
I created my LaTeX environment with Docker. The Dockerfile is
FROM korosuke613/ubuntu-texlive-ja:latest
WORKDIR /workdir
RUN apt update \
&& apt install -y \
texlive-extra-utils \
make \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
Build with command
docker build -t latex-dev:1.0.0 .
OK, that’s all. I use latexmk to compile document and re-use the .latexmkrc
file in the Windows system.
#!/usr/bin/env perl
$pdf_mode = 3;
$latex = 'platex %O -kanji=utf8 -no-guess-input-enc -interaction=nonstopmode -file-line-error %S';
$bibtex = 'pbibtex %O %B';
$dvipdf = 'dvipdfmx %O -o %D %S';
$makeindex = 'mendex %O -o %D %S';
$biber = 'biber %O --bblencoding=utf8 -u -U --output_safechars %S';
$makeindex = 'mendex %O -o %D %S';
$pvc_view_file_via_temporary = 0;
$pdf_previewer = 'C:/Users/student/AppData/Local/SumatraPDF.exe -reuse-instance'
Let’s compile
Get inside the Docker container.
docker run --rm -it -v ${PWD}:/workdir latex-dev:1.0.0 /bin/bash
I assume “the current directory” is the same with Dockerfile. Move to the document directory in the container and compile with
latexmk
Congratulations! You got the efficient LaTeX environment in your Windows PC. Enjoy your LaTeX life.