Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!


sphinxcontrib-texfigure -- TeX Figure extension for Sphinx


sphinxcontrib-texfigure is a Sphinx extension for generating figures and diagrams from TeX files.

For an example of a diagram this extension could produce, please see For more examples, see demo directory in the source distribution.

This extension is similar in scope to sphinxcontrib-tikz extension, but with different approach to input and options.

This software is written by Kirill Simonov (Prometheus Research, LLC) and released under BSD license.


The following executables are used for rasterizing TeX documents:

  • pdflatex
  • pdftoppm
  • pnmcrop
  • pnmtopng

On a Debian or a Debian-derived system, they could be installed with:

# apt-get install texlive
# apt-get install poppler-utils
# apt-get install netpbm

If you want to generate diagrams with TikZ, install:

# apt-get install texlive-pictures


To enable this extension, add the following line to


Use texfigure directive to convert a TeX/LaTeX document to an image. For example:

.. texfigure:: hello-world.tex

This directive will render Hello, World! in a box assuming that hello-world.tex contains the following LaTeX document:


\node[draw] {Hello, World!};

Use option align to specify horizontal alignment, alt to specify text content of the image:

.. texfigure:: hello-world.tex
   :align: center
   :alt: Hello, World!




Renders a figure from a TeX document.

The parameter of the directive must be the path to a TeX/LaTeX file. This directive has no body.


Horizontal alignment (left, center, or right)
Alternative text content of the image.

Configuration parameters

texfigure_pdftex (default: pdflatex)
Path to pdftex or pdflatex executable.
texfigure_pdftoppm (default: pdftoppm)
Path to pdftoppm executable.
texfigure_pnmcrop (default: pnmcrop)
Path to pnmcrop executable.
texfigure_pnmtopng (default: pnmtopng)
Path to pnmtopng executable.
texfigure_texinputs (default: [])
List of directories where TeX searches for input files.
texfigure_resolution (default: 110)
Image resolution, in DPI.

CSS classes

Applies to the generated image.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.