You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bertrand Benjamin 7bbaf1132d Feat: add example 3 months ago
pytex Feat: pdflatex argument can be a str 11 months ago
tests Feat: test in tmp dir and few bug correction 11 months ago
.gitignore Feat: add .pytest_cache/ 3 months ago
LICENSE Start Pytex project 3 years ago Feat: add example 3 months ago
requirements.txt Update requirement 3 years ago Fix: change version to correspond to pipy version 3 months ago


Pytex is a simple package which make a bridge between Latex and Python.


pip install mypytex

texenv: Bring Python inside latex

texenv is a jinja2 environment which allow to use python commands inside latex.

  • \Block{#} is the equivalent of {% block #%} in Jinja2. Every python's commands will be run like in a script. %- is also available for line statement.
  • \Var{#} is the equivalent of {{#}} which print the statment.

Use the environment with a string template.

>>> from pytex import texenv

>>> text = "Hello"
>>> template = """\
\Block{set a = 2}
%-set b = 3

>>> template = texenv.from_string(template)
>>> print(template.render(text = text)


feed: converting template into tex files

pdflatex: Compile files with pdflatex

update_export_dict: import extract tools inside template