diff --git a/README.md b/README.md index 4a5a481..8f15937 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://drone.opytex.org/api/badges/lafrite/Bopytex/status.svg)](https://drone.opytex.org/lafrite/Bopytex) -Bopytex is a command line tool for producing random math exercises with their correction. It embeds [mapytex](https://git.opytex.org/lafrite/Mapytex) and [python](python.org) into [latex](latex-project.org) through [jinja](jinja.pocoo.org). +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 @@ -12,84 +12,75 @@ Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/) ## Simple example -Let's say I want an exercise on adding 2 fractions (files are in `examples`). +``` latex +% save this as tpl_simple.tex +\documentclass[12pt]{article} -The *latex* template called `tpl_add_fraction.tex` +\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 + +``` bash +$ 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 1", "k>1"]) -\[ - A = \Var{e} -\] -Solution -\[ - \Var{e.simplify().explain() | join('=')} -\] -\end{document} -``` +%- set e = Expression.random("{a} + {b}") +\Var{e} -Generate latex files and compile those for 2 different subjects. - -``` -bopytex -t tpl_add_fractions.tex -N 2 -``` - -It produces 2 sources files - -- `01_add_fractions.tex` - -```latex -\documentclass[12pt]{article} - -\begin{document} - -\section{Ajouts de fractions} - -Adding two fractions -\[ - A = \frac{- 2}{4} + \frac{7}{8} -\] -Solution -\[ - \frac{- 2}{4} + \frac{7}{8}=\frac{- 2 \times 2}{4 \times 2} + \frac{7}{8}=\frac{- 4}{8} + \frac{7}{8}=\frac{- 4 + 7}{8}=\frac{3}{8} -\] +\Var{e.simplify()} \end{document} ``` -- `02_add_fractions.tex` +Then I can produce multiple documents (3 here) -```latex -\documentclass[12pt]{article} - -\begin{document} - -\section{Ajouts de fractions} - -Adding two fractions -\[ - A = \frac{8}{9} + \frac{3}{63} -\] -Solution -\[ - \frac{8}{9} + \frac{3}{63}=\frac{8 \times 7}{9 \times 7} + \frac{3}{63}=\frac{56}{63} + \frac{3}{63}=\frac{56 + 3}{63}=\frac{59}{63} -\] - -\end{document} +``` bash +$ bopytex tpl_simple.tex -q 3 -c bopytex_config.py ``` - -And a ready to print pdf. - -- [ all_add_fraction.pdf ]( ./examples/all_add_fraction.pdf ) - - - - -