latex docker chapter done

This commit is contained in:
2026-09-24 15:01:30 -04:00
committed by GitHub
parent 95c614fb95
commit 526085153c
5 changed files with 50 additions and 16 deletions
+46
View File
@@ -1,3 +1,49 @@
\chapter{LaTeX Docker}
\ChapterLabel{LatexDocker}
To compile a LaTeX file through a Docker container, the first step was to create a Dockerfile. Using the texlive and latexmk frameworks, we created this Dockerfile:
\begin{minted}{javascript}
FROM debian:bookworm-slim
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
texlive-latex-base \
texlive-latex-recommended \
texlive-latex-extra \
texlive-fonts-recommended \
latexmk \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /data
CMD ["latexmk", "-pdf", "main.tex"]
\end{minted}
The file uses a lightweight Debian base to install the requird tools from texlive and latexmk. From there, it establishes /data as the working directory of the container, and runs a command to compile a LaTeX file named "main.tex".
\newpage
From there, we build the container by placing the Dockerfile inside the directory of the LaTeX project and running:
\begin{minted}{bash}
docker build -t my-latex-compiler .
\end{minted}
This sets up the container, named "my-latex-compiler" for use. To start the container and compile the LaTeX project, we run:
\begin{minted}{bash}
docker run --rm -v "$(pwd):/data" my-latex-compiler
\end{minted}
Once the command runs, a main.pdf file is created inside the LaTeX project directory, containing the compiled project. To test this, we ran the container on a barebones sample document containing some text, an image, and a table. The compiler created an identical result to downloading the document as a pdf from Overleaf, proving its success. The only downsides are that the primary .tex file of the project being compiled must be named main.tex, and that LaTeX errors that Overleaf can still compile through cannot be ignored by our compiler. These can be overcome by changing the expected name in the Dockerfile and being more thorough in error fixing when manually editing the LaTeX.
\begin{figure}[hbt!]
\centering
\includegraphics[width=1\linewidth]{sample.pdf}
\caption{The pdf result of the Docker compiler on our sample document, with whitespace cropped out for readability.}
\label{fig:placeholder}
\end{figure}