LaTeX workflows beyond full documents

Most LaTeX users eventually discover that the toolchain is good for more than producing complete papers. Two common use cases are rendering math for web publications and maintaining shorter personal notes. Both can be handled with a combination of local editors, command-line converters, and a handful of utility scripts.

For everyday authoring, TeXstudio is a solid choice. It layers a convenient preview window over the standard command-line tooling without obscuring what happens underneath. Users who prefer web-based collaboration might lean toward Overleaf, but for local, git-backed text files, TeXstudio’s transparency and logging are hard to beat.

Bridging to blog formats

pandoc makes it straightforward to translate LaTeX documents into other markup languages. Writing math-heavy posts in LaTeX first, then converting to reStructuredText, has become a practical route for some authors. A typical conversion looks like this:

$ pandoc -f latex -s -t rst hilbert.tex

The output is clean enough that only minor adjustments are needed before publishing. Since pandoc supports many target formats, the same approach works equally well for Markdown or other systems.

Isolated formula rendering

LaTeX also excels at producing standalone images of individual equations. A single expression can be placed in its own .tex file, such as standaloneformula.tex, and compiled directly to an image.

\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
\(
\int_{-\infty}^\infty e^{-x^2}\,dx=\sqrt{\pi}
\)
\end{document}

The example above represents the Gaussian integral. With the texlive package installed via a package manager, the standard tools become available:

$ sudo apt install texlive-full

Running pdflatex on the file generates a PDF suitable for previewing:

$ pdflatex standaloneformula.tex

For web use, vector or raster images are often preferable. A two-step process handles the conversion to SVG:

$ latex standaloneformula.tex

... generates standaloneformula.dvi

$ dvisvgm standaloneformula.dvi

... generates standaloneformula.svg

If a PNG is required instead, a similar command sequence applies:

$ dvipng -D 300 standaloneformula.dvi

The latexmk utility adds a useful convenience: it watches the input file and rebuilds the PDF automatically on every change. While that is handy in some contexts, TeXstudio already offers comparable live preview functionality.

The identical workflow applies to TikZ graphics. A standalone document containing a single tikzpicture can be converted to SVG or PNG with the same commands.

Running via Docker

For those who prefer to avoid installing a full LaTeX distribution, the texlive Docker image provides an alternative. After pulling the image, the same commands can be executed through Docker:

$ docker pull texlive/texlive:latest
$ docker run --rm -u $(id -u):$(id -g) \
    -v "$PWD":/workdir -w /workdir texlive/texlive:latest \
    latex standaloneformula.tex

$ docker run --rm -u $(id -u):$(id -g) \
    -v "$PWD":/workdir -w /workdir texlive/texlive:latest \
    dvisvgm standaloneformula.dvi

Aligning inline equations

Embedding a formula within running text requires careful vertical alignment to match the surrounding font metrics. Tools like dvisvgm and dvipng output the necessary measurements:

$ dvisvgm standaloneformula.dvi
pre-processing DVI file (format version 2)
processing page 1
  computing extents based on data set by preview package (version 14.0.6)
  width=81.267395pt, height=9.86894pt, depth=4.388947pt
  graphic size: 81.267395pt x 14.257887pt (28.562223mm x 5.011074mm)
  output written to standaloneformula.svg
1 of 1 page converted in 0.147623 seconds

The height=..., depth=... values indicate the formula’s total height and how far it dips below the text baseline. These numbers can be mapped directly to CSS properties when embedding the image on a web page: height becomes style="height: ... and depth becomes vertical-align: ....