Go to file
Bertrand Benjamin b2bbc0a24f
continuous-integration/drone/push Build is passing Details
Feat: add readmin in pyproject.toml
2022-07-28 10:01:15 +02:00
bopytex Fix: run pre-commit hooks 2022-07-28 09:39:51 +02:00
documentation Fix: run pre-commit hooks 2022-07-28 09:39:51 +02:00
example Fix: run pre-commit hooks 2022-07-28 09:39:51 +02:00
test Fix: run pre-commit hooks 2022-07-28 09:39:51 +02:00
.drone.yml Fix: only on tagging? 2020-08-20 16:27:17 +02:00
.gitignore core: remove tests from .gitignore 2022-04-14 11:29:39 +02:00
.pre-commit-config.yaml Core: add pre-commit config 2022-07-28 09:39:20 +02:00
Dockerfile.simple Feat: move Dockerfile to Dockerfile.simple 2022-07-19 17:28:19 +02:00
Dockerfile.usecase Feat: rename dockerfile from mapytex to usecase 2022-07-19 17:13:23 +02:00
MANIFEST.in spelling and wrong arg 2015-05-16 10:50:03 +02:00
Makefile Fix: run pre-commit hooks 2022-07-28 09:39:51 +02:00
README.md Feat: update README 2022-07-20 16:44:03 +02:00
poetry.lock Core: Add pre-commit int dev-dependencies 2022-07-28 09:29:14 +02:00
pyproject.toml Feat: add readmin in pyproject.toml 2022-07-28 10:01:15 +02:00
requirements.txt Feat: Create dockerfile to test in new env 2022-05-04 18:03:58 +02:00
setup.py Feat: dockerfile to test bopytex in new environment 2022-05-08 09:15:13 +02:00

README.md

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

direct_access = {
    "Expression": Expression,
    "random": 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{ subject.name }}

\begin{document}

\maketitle

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

\Var{e.simplify()}

\end{document}

Information about my students are stored in a csv file (here students.csv)

"Name","Age","Email","fraction level","calculus level"
"Spike Tucker","22","s.tucker@randatmail.com","7","3"
"Martin Payne","21","m.payne@randatmail.com","7","3"
"Kimberly Baker","20","k.baker@randatmail.com","1","8"
"Emma Bailey","29","e.bailey@randatmail.com","2","5"
"Nicholas Taylor","28","n.taylor@randatmail.com","3","3"

Then I can produce a subject for each of my student

$ bopytex tpl_simple.tex -s students.csv -c bopytex_config.py