Skip to main content

Quickly build beautiful LaTeX documents from python/pandas

Project description


Generating pretty reports using pandas and matplotlib, Seaborn or Altair.


  • pip install pantex to install the main application
  • Install MiKTeX (on Windows) or TBD on Linux
  • Install pandoc
  • Install Browsersync (for browser mode): npm install -g browser-sync
  • Install chromdriver.exe for Altair and make sure it's on your system path


To create a pantex.Manager object:

m = pantex.Manager('')

To save context to mytemplate.pkl:

m.save_context({'my_header': 'Hello World!', 'my_table': df.head()})

To append to context in a Python script:

m.save_context({'my_footer': 'Goodbye!', 'an_image': mplFigure}, append=True)

To generate a pretty pdf report:


To read the current context in a Python script: m.get_context()


To generate a pdf report using a in-memory context dictionary:

m = pantex.Manager('', {'my_header': 'Hello World!', 'my_table': df.head()})

Quickstart via Command Line

To run in browser mode: python -m pantex.edit
To prduce a pretty LaTeX pdf report: python -m pantex.publish

How it works

Inspired by traditional website rendering, a report generation process is divided into two parts:

  1. A markdown template with Python-native template variables.
  2. A context dictionary, which is saved at mytemplate.pkl

For example, say you have a markdown file at ./, containing:

# ${my_header}
Some text

In Python, you can write:

m = pantex.Manager('')
m.save_context({'my_header': 'Hello World!', 'my_table': df.head()})

panTeX will combine the markdown template and the Python context and produce a pretty pdf LaTeX report. Note that pandas DataFrame objects will be automatically rendered as a table. Matplotlib/Seaborn charts and LaTeX style equations are also supported. (The LaTeX equations must be contained in \begin{equation}/\end{equation} tags.)

matplotlib and Seaborn plot can also be added to the context. For example,

import seaborn as sns
df = sns.load_dataset("tips")
sns_plot = sns.relplot(
m = pantex.Manager('')
m.save_context({'pretty_figure': sns_plot}, append=True)  # "Pretty Figure" will be the image caption

Behind the scenes, panTeX saves the image at assets/pretty_figure.eps and adds ![Pretty Figure](assets/pretty_figure.eps) to the rendered version of markdown file.

The Development Server (Edit Mode)

python -m pantex.edit enables an in-browser version of the LaTeX report. It's not quite as pretty as the pdf version, but it offers a near real time rendering experience. (Rendering of pdf reports is typically too slow for editing and requires the file to re-opened after each render.) If you need the html files, they can be found at mytemplate.html and assets/.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panTeX-0.0.9.tar.gz (9.5 kB view hashes)

Uploaded source

Built Distribution

panTeX-0.0.9-py3-none-any.whl (7.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page