pytex/README.md

51 lines
930 B
Markdown
Raw Permalink Normal View History

2020-08-06 14:42:39 +00:00
# Pytex
2017-08-15 06:56:29 +00:00
2018-05-19 08:08:29 +00:00
Pytex is a simple package which make a bridge between Latex and Python.
2017-08-15 06:56:29 +00:00
2020-08-14 13:46:10 +00:00
## Installation
``` bash
pip install mypytex
```
2020-08-06 14:42:39 +00:00
## texenv: Bring Python inside latex
2017-08-15 06:56:29 +00:00
*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.
2020-08-14 13:46:10 +00:00
Use the environment with a string template.
``` python
>>> 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
```
2017-08-15 06:56:29 +00:00
2020-08-06 14:42:39 +00:00
## feed: converting template into tex files
2017-08-15 06:56:29 +00:00
2020-08-06 14:42:39 +00:00
## pdflatex: Compile files with pdflatex
2017-08-15 06:56:29 +00:00
2020-08-06 14:42:39 +00:00
## update_export_dict: import extract tools inside template
2017-08-15 06:56:29 +00:00