diff --git a/Makefile b/Makefile index c9f4401..33b6ad3 100644 --- a/Makefile +++ b/Makefile @@ -2,10 +2,18 @@ docker-build-simple: docker build -f Dockerfile.simple -t simple . docker-simple: docker-build-simple - docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat 1_example.tex" + docker run simple sh -c "bopytex -q 2 tpl_example.tex && ls" docker-build-usecase: docker build -f Dockerfile.usecase -t usecase . docker-usecase: docker-build-usecase docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat 1_example.tex" + +usecase-example: docker-build-usecase + docker run usecase sh -c "bopytex -s students.csv tpl_example.tex && cat joined_example.pdf" > example/usecase/joined_example.pdf + +simple-example: docker-build-simple + docker run simple sh -c "bopytex -q 2 tpl_example.tex && cat joined_example.pdf" > example/simple/joined_example.pdf + +examples: usecase-example simple-example diff --git a/README.md b/README.md index f141b95..9ec6b1f 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ We have two variables ``` -To create a version a this document type this +The following command produces the [joined_example.pdf](./example/simple/joined_example.pdf) document ``` bash $ bopytex tpl_simple.tex @@ -58,11 +58,11 @@ To produce formulas and values, I use an another tool I an developing: `mapytex ``` python # bopytex_config.py from mapytex import Expression -from random import random + +random.seed(0) # Controlling the seed allows to make subject reproductible direct_access = { "Expression": Expression, - "random": random } ``` @@ -83,6 +83,27 @@ Every variables, objects or function inside this file will be available inside t \Var{e.simplify()} + +\section{Variables} +\subsection{subject} +\begin{itemize} +%- for k,v in subject.items() + \item +\begin{verbatim} + \Var{k}: \Var{v} +\end{verbatim} +%- endfor +\end{itemize} +\subsection{options} +\begin{itemize} +%- for k,v in options.items() + \item +\begin{verbatim} + \Var{k}: \Var{v} +\end{verbatim} +%- endfor +\end{itemize} + \end{document} ``` @@ -97,12 +118,13 @@ Information about my students are stored in a csv file (here `students.csv`) "Nicholas Taylor","28","n.taylor@randatmail.com","3","3" ``` -Then I can produce a subject for each of my student +Then I can produce a [subject for each of my student](./example/usecase/joined_example.pdf) ``` bash $ bopytex tpl_simple.tex -s students.csv -c bopytex_config.py ``` + ## Running examples I build two examples base of the simple example and how I use it. They are playable through dockerfiles with make commands. diff --git a/example/simple/joined_example.pdf b/example/simple/joined_example.pdf index a1c4cac..2b70072 100644 Binary files a/example/simple/joined_example.pdf and b/example/simple/joined_example.pdf differ diff --git a/example/simple/tpl_example.tex b/example/simple/tpl_example.tex index c02be2c..8e32a89 100644 --- a/example/simple/tpl_example.tex +++ b/example/simple/tpl_example.tex @@ -22,9 +22,23 @@ We have two variables \section{Variables} \subsection{subject} -\Var{subject} +\begin{itemize} +%- for k,v in subject.items() + \item +\begin{verbatim} + \Var{k}: \Var{v} +\end{verbatim} +%- endfor +\end{itemize} \subsection{options} -\Var{options} +\begin{itemize} +%- for k,v in options.items() + \item +\begin{verbatim} + \Var{k}: \Var{v} +\end{verbatim} +%- endfor +\end{itemize} \end{document} diff --git a/example/usecase/bopytex_config.py b/example/usecase/bopytex_config.py index 014a874..6c7f402 100644 --- a/example/usecase/bopytex_config.py +++ b/example/usecase/bopytex_config.py @@ -1,3 +1,7 @@ +import random + from mapytex import Expression -direct_access = {"Expression": Expression} +random.seed(0) + +direct_access = {"Expression": Expression, "random": random.random} diff --git a/example/usecase/joined_example.pdf b/example/usecase/joined_example.pdf index fb2fd5d..4f06db1 100644 Binary files a/example/usecase/joined_example.pdf and b/example/usecase/joined_example.pdf differ diff --git a/example/usecase/tpl_example.tex b/example/usecase/tpl_example.tex index c69211e..80d128f 100644 --- a/example/usecase/tpl_example.tex +++ b/example/usecase/tpl_example.tex @@ -15,8 +15,22 @@ \section{Variables} \subsection{subject} -\Var{subject} +\begin{itemize} +%- for k,v in subject.items() + \item +\begin{verbatim} + \Var{k}: \Var{v} +\end{verbatim} +%- endfor +\end{itemize} \subsection{options} -\Var{options} +\begin{itemize} +%- for k,v in options.items() + \item +\begin{verbatim} + \Var{k}: \Var{v} +\end{verbatim} +%- endfor +\end{itemize} \end{document}