SummaryConverts the content (LaTeX TikZ picture commands) into an image
Short nametikz
Content typetext
Extension mapping{"tikz"=>"png"}
Provided by bundlebuilt-in
API docWebgen::ContentProcessor::Tikz


This content processor provides support for automatically generating graphics via the fantastic PGF/TikZ library for LaTeX.


You will need to have a current LaTeX distribution with the PGF/TikZ library and ImageMagick or GraphicsMagick installed for this to work. You will also need Ghostscript if you want support for transparent PNG images and pdf2svg for SVG output support.

More exactly, you will need to have the following programs available in the binary search path:

This program is usually included in the LaTeX distribution. It is used for generating a PDF from the LaTeX document that describes the PGF/TikZ graphic.
This program is provided by ImageMagick or GraphicsMagick. It is used to convert the generated PDF document to an image file and to optionally resize it.
This program is provided by ImageMagick or GraphicsMagick. It is used to determine the exact size of the generated image file.
This program is provided by the Ghostscript package. It is used for generating transparent PNG images.
This program converts the generated PDF to an SVG file.

If you are using Ubuntu Linux you can install everything that is needed by running the following command:

$ sudo aptitude install texlive pgf ghostscript imagemagick pdf2svg


This content processor is normally used in one of the following ways:

  • Either with the tag tikz which provides an easy way to insert an image tag and generate a TikZ picture at the same time.

  • Or in combination with the path handler copy. An easy way to do this is by creating a file with the tikz extension. This file is automatically handled by the path handler copy which changes its extension to png and processes it with this processor.

The content needs to contain just the PGF/TikZ image commands because the content processor itself automatically wraps it with the approriate LaTeX commands to create a full LaTeX document which is then converted to an image.

There are some configuration options for configuring the behaviour of this processor:

Custom LaTeX Templates

If you want to use a custom LaTeX template, the following special objects are available:

Contains the PGF/TikZ commands for the image.
The value for the configuration option OPTION_NAME. This should be used instead of[OPTION_NAME] since the value may have been changed.

Here is an example for such a LaTeX template:

--- name:content pipeline:erb

<% if context['content_processor.tikz.libraries'] %>
\usetikzlibrary{<%= context['content_processor.tikz.libraries'].join(',') %>}
<% end %>

\begin{tikzpicture}[<%= context['content_processor.tikz.opts'] %>]
<%= context['data'] %>


Have a look at the tag tikz to see example input and the generated images.