PyLaTeX¶
PyLaTeX is a Python library for creating and compiling LaTeX files. The goal of this library is to be an easy, but extensible interface between Python and LaTeX.
PyLaTeX has two quite different usages: generating full pdfs and generating LaTeX snippets. Generating full pdfs is mostly useful when all the text that pdf should contain is generated by python, for instance exporting the data from a database. Snippets are useful when some text still needs to be written by hand, but some stuff can be automatically generated, for instance writing a report with a couple of matplotlib plots.
Installation¶
PyLaTeX works on Python 2.7 and 3.3+ and it is simply installed using pip:
pip install pylatex
Some of the features require other libraries as well. This is mostly the case when converting a datatype of that library to LaTeX. For instance, generating LaTeX matrices requires Numpy. The dependencies for these extra features can simply be installed like this:
pip install pylatex[matrices]
The features that require additional libraries are:
- matrices
- matplotlib
- quantities
Code¶
To see the some code in action, please take a look at the Full example, which generates the pdf below. To understand how the code works, please look at the Library usage.
Support¶
This library is being developed in and for Python 3. Because of a conversion script the current version also works in Python 2.7. For future versions, no such promise will be made. Python 3 features that are useful but incompatible with Python 2 will be used. If you find a bug for Python 2 and it is fixable without ugly hacks feel free to send a pull request.
This library is developed for Linux. I have no intention to write fixes or test for platform specific bugs with every update, especially since I have no other operating systems to test it on. Pull requests that fix those issues are always welcome though. Issues have been fixed for Windows and it seems that compiling to pdf is currently working.
Contributing¶
Read the How to contribute page for tips and rules when you want to contribute. To just see the source code, you should go to the Github repository.