Bertrand Benjamin 67656c2cf1 Feat: arrange variables for templates
Split in 3 categories
- from "options" key build with default_config, file_config and cli options
- from "subject" key build csv or quantity of subject
- other in direct access from "direct_access" dictionnary inside the
  file_config
2022-07-20 16:16:09 +02:00
2017-04-17 17:04:14 +03:00
2022-07-19 18:09:17 +02:00
2020-08-20 16:27:17 +02:00
2022-04-14 11:29:39 +02:00
2022-07-19 17:28:32 +02:00
2015-05-16 10:50:03 +02:00

Bopytex

Build Status

Bopytex is a command line tool which embed python into latex. It uses jinja2 to do so with a modified environnement to match with latex syntax.

Installing

Install and update using pip

pip install -U bopytex

Simple example

% save this as tpl_simple.tex
\documentclass[12pt]{article}

\title{Bopytex example -- {{ number }}}

\begin{document}

\maketitle
%- set a = 10
%- set n = 2
We have two variables
\begin{itemize}
    \item a: \Var{a}
    \item n: \Var{n}
\end{itemize}

%# We can use blocks
\begin{itemize}
%- for i in n
    \item \Var{a}
%- endfor
\end{itemize}


\end{document}

To create a version a this document type this

$ bopytex tpl_simple.tex

How I use it

I build this program to produce individual exams subjects for each of my student with the correction associated. I write a template, and bopytex build subject and correction.

To produce formulas and values, I use an another tool I an developing: mapytex <https://git.opytex.org/lafrite/Mapytex. I am importing it through bopytex_config.py.

# bopytex_config.py
from mapytex import Expression
from random import random

Every variables, objects or function inside this file will be available inside the template.

% tpl_example.tpl
\documentclass[12pt]{article}

\title{Bopytex with Mapytex example -- \Var{ number }}

\begin{document}

\maketitle

%- set e = Expression.random("{a} + {b}")
\Var{e}

\Var{e.simplify()}

\end{document}

Then I can produce multiple documents (3 here)

$ bopytex tpl_simple.tex -q 3 -c bopytex_config.py
Description
No description provided
Readme 6.7 MiB
Languages
Python 95.8%
TeX 2.6%
Makefile 1.6%