No Description
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.
Benjamin Bertrand b522c0a174 Doc: ... 3 months ago
pytex Fix: bug with path in pdflatex 3 months ago
.gitignore Start Pytex project 2 years ago
LICENSE Start Pytex project 2 years ago
README.md Doc: ... 3 months ago
requirements.txt Update requirement 2 years ago
setup.py Change name to mypytex in setup to push it to pipy 2 years ago

# Pytex

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

## Install

pip install mypytex


## Usage

• Latex template file tpl_test.tex.
\documentclass{article}

\begin{document}

%# Init variables
\Block{set a = 1}
%- set b = 2

\begin{itemize}
\item a = \Var{a}
\item b = \Var{b}
\item a + b = \Var{a} + \Var{b} = \Var{a+b}
\end{itemize}

\end{document}

• Turn it to latex with pytex
>>> import pytex
>>> pytex.feed("./tpl_test.tex")


It creates a new file 01_test.tex

\documentclass{article}

\begin{document}

\begin{itemize}
\item a = 1
\item b = 2
\item a + b = 1 + 2 = 3
\end{itemize}

\end{document}

• Compile it
>>> pytex.pdflatex("./01_test.tex")


## 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.

To comment a line for latex and pytex, it has to start with %#.