Go to file
2020-08-14 15:46:10 +02:00
pytex Feat: pdflatex argument can be a str 2019-12-28 09:42:38 +01:00
tests Feat: test in tmp dir and few bug correction 2019-12-23 14:29:15 +01:00
.gitignore Feat: add .pytest_cache/ 2020-08-06 16:45:52 +02:00
LICENSE Start Pytex project 2017-04-16 11:57:14 +03:00
README.md Feat: add example 2020-08-14 15:46:10 +02:00
requirements.txt Update requirement 2017-04-16 17:23:14 +03:00
setup.py Fix: change version to correspond to pipy version 2020-08-06 16:44:48 +02:00

Pytex

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

Installation

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 = """\
\Var{text}
\Block{set a = 2}
%-set b = 3
\Var{a}
\Var{b}
"""

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

2
3


feed: converting template into tex files

pdflatex: Compile files with pdflatex

update_export_dict: import extract tools inside template