Usage

Configuration

Setup is done using the following environment variables:

Variable Notes Default
LATEXRENDER_OUTPUT_DIR Directory where image files will be saved and served from /tmp/latexrender/
LATEXRENDER_TEMPLATE Jinja2 template to use for rendering the LaTeX snippet. template.tex in installation directory
LATEXRENDER_XELATEX Location of xelatex executable. (Auto)
LATEXRENDER_DVIPNG Location of dvipng executable. (Auto)
USE_X_SENDFILE Whether to use X-Sendfile or serve the generated image directly. True
LATEXRENDER_SENDFILE_ROOT A root directory to prepended to the X-Sendfile header sent to the upstream proxy. Empty string

If not specified your path will be inspected to find latex and dvipng.

The default template, in Jinja2 format, is

{# vim: set ft=jinja ts=4 sw=4 tw=0 et :#}
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}
\usepackage{cancel}
\pagestyle{empty}
\begin{document}
\huge
{{ latex }}
\end{document}

Deploying

Run using your favourite WSGI server:

chausette latexrender.app
gunicorn latexrender:app

It is recommended that you run this behind a frontend proxy such as nginx and use X-Sendfile to have that serve the image files.

Pass base64 encoded LaTeX snippets as the URL in one of the following forms:

http://localhost:8080/<b64latex>/
http://localhost:8080/<b64latex>.png

In the default template the surrounding math environment is not specified so you can, for example, use input of the form:

$$ e^{i\pi} + 1 = 0 $$

or:

\begin{equation*}
    e^{i\pi} + 1 = 0
\end{equation}
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.