Skip to content
Permalink
Browse files

Added LaTeX formula renderer plugin.

  • Loading branch information
felixfontein committed Jan 14, 2017
1 parent c8f4a70 commit 2fc1fb6acce43e5b83d25dee9f8549d43ec522f7
@@ -0,0 +1,17 @@
The `latex_formula_renderer` plugin provides a static LaTeX formula rendering infrastructure, generating images which can be included in a website and do not depend on client-side rendering of formulae (as with [MathJax](https://www.mathjax.org/) and [KaTeX](https://khan.github.io/KaTeX/)). This plugin is not for end-users, but provided as a service for other plugins which can use it to not having to define their own formula-rendering functionality.

The plugin has support for
* inline formulae, display-style formulae,
* `align` environments (see the [AMSMath documentation](ftp://ftp.ams.org/ams/doc/amsmath/amsldoc.pdf)),
* XY-pic diagrams (in `xymatrix` environments inside any of the previous; see the [XY-Pic user guide](http://texdoc.net/texmf-dist/doc/generic/xypic/xyguide.pdf)),
* pstricks graphics (see [here](https://en.wikipedia.org/wiki/PSTricks) for more information), and for
* tikzpicture graphics (see [here](https://en.wikibooks.org/wiki/LaTeX/PGF/TikZ) for more information).

It allows to generate formulae in different output formats:
* as `.png` bitmap images;
* as `.svg` vector graphics;
* as compressed `.svgz` vector graphics.

The generated images do not require the user to have a certain font installed, and should render the same in all browsers and on all output devices (assuming they support the chosen graphics format and don't screw up basic things).

To see how the plugin can be used, please check out the docstring of `LaTeXFormulaRendererPlugin` in `latex_formula_renderer.py`.
@@ -0,0 +1,40 @@
# The folder relative to OUTPUT_FOLDER in which the rendered formulae are stored.
# Defaults to /formula/.
LATEX_FORMULA_FOLDER = "formula"

# Whether to store the rendered formulae as images or to insert them with data URIs.
# Warning: data URIs can seriously blow up the generated HTML, especially if you
# use may formulae or repeatingly the same one!
LATEX_FORMULA_AS_DATAURI = False

# The output format used for the images. Possible values:
# * "png" for PNG images with transparency;
# * "svg" for SVG vector graphics;
# * "svgz" for SVG vector graphics compressed with gzip.
# Note that depending on your web server's configuration, you might experience
# problems with .svgz files as the web server might treat them similar to .svg.gz
# files and deliver them claiming that they are .svg files.
LATEX_FORMULA_OUTPUT_FORMAT = 'png'

# Allows to include packages and define things in the preamble of the .tex files
# used to render the formulae. When generating a temporary .tex file, the plugin
# looks for the contents of the following keys:
# * "": will always be included;
# * "tikz": will be included when formula_type is ("tikzpicture", ...);
# * "pstricks": will be included when formula_type is ("pstricks", ...);
# * "xy": will be included if the formula contains "\xymatrix";
# * "pdflatex": will be included if the .tex file is processed by pdflatex
# to convert it to a .pdf file;
# * "latex": will be included if the .tex file is processed by latex to convert
# it to a .dvi file.
# The default is {}, which means no preamble additions. The following example
# shows how to define some macros for all formulae:
LATEX_FORMULA_ADDITIONAL_PREAMBLE = {
"": r"""
\usepackage{amssymb}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}"""
}
@@ -0,0 +1,13 @@
[Core]
Name = latex_formula_renderer
Module = latex_formula_renderer

[Nikola]
PluginCategory = Task
MinVersion = 7.8.2

[Documentation]
Author = Felix Fontein
Version = 1.0
Website = https://felix.fontein.de
Description = Provides a LaTeX formula rendering infrastructure

0 comments on commit 2fc1fb6

Please sign in to comment.
You can’t perform that action at this time.