# Packages for LaTeX templating in julia (and symbolic algebra)

**URL:** <https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923>\
**Category:** General Usage\
**Tags:** latex\
**Created:** [February 24, 2021, 10:18am UTC](https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923 "2021-02-24T10:18:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Post date:** [February 24, 2021, 10:18am UTC](https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923/1 "2021-02-24T10:18:51Z")

</div>

I want to make some tutorial sheets and fill them with partly randomised questions. I’m thinking of using some kind of template library in julia to replace certain tags in the document with questions (and separately with answers).

I’ve worked with jinja before in python, but ideally there’s a pure julia implementation I can play with. Any suggestions?

While I’m at it, any suggestions for packages to do some symbolic algebra. I’d like to be able to simplify expressions, factorise expressions, rearrange equations to solve for a given variable and solve systems of equations (ideally in julia). All of this is for middle / high school level maths, so I don’t need to be able to solve anything crazy.

---

<div class="post-metadata">

**Author:** ![j\_verzani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/j_verzani/32/8551_2.png) [@j\_verzani](https://discourse.julialang.org/u/j_verzani)\
**Post date:** [February 25, 2021, 2:42am UTC](https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923/2 "2021-02-25T02:42:14Z")

</div>

It might not fit how you envision this all working, but if you want to leverage a tool like WeBWorK for the task of problem display, randomization, and score management then you might find this unregistered package of interest:  
[JuliaWeBWorK](https://github.com/mth229/JuliaWeBWorK.jl).

This allows you to author questions for WeBWorK as Julia scripts, using markdown with math markup in LaTeX and Mustache for variable substitution, such as is used for randomization. Randomization is created `Julia` side, so you can leverage symbolic math in computing acceptable answers (such as provided by [SymPy](https://github.com/JuliaPy/SymPy.jl).

Some example scripts for producing a collection of questions can be seen [here](https://github.com/mth229/JuliaWeBWorK.jl/tree/master/examples).

The basic work flow is you write a script, execute it to create a `pg` file and then add that to a WeBWorK installation. The [demo site](https://demo.webwork.rochester.edu/webwork2/wikiExamples/MathObjectsLabs2/1/) is useful for debugging a pg file generated by the script.

We use this package for a class, so it has some testing, but for sure there are features to add and bugs to find. If you are interested and find something, please file an issue.

---

<div class="post-metadata">

**Author:** ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Post date:** [February 26, 2021, 7:41am UTC](https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923/3 "2021-02-26T07:41:48Z")

</div>

I had a look at JuliaWeBWorK, but the lack of tests and docs put me off a little. I also played around with using weave to make sheets, but that’s not quite what I want. I ended up finding [Mustache.jl](https://github.com/jverzani/Mustache.jl) (which I just saw @j_verzani is also involved in, XD). Mustache is pretty much exactly what I was looking for. It’s simple, easy and has everything I need. 🙂

Edit: for symbolic manipulation I found a bunch of packages in pure julia. I’m gonna play with [SymEngine.jl](https://github.com/symengine/SymEngine.jl) for now.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [February 26, 2021, 7:55am UTC](https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923/4 "2021-02-26T07:55:31Z")

</div>

Not that it’s necessarily relevant or problematic, but SymEngine.jl is a wrapper around a C++ library.

The equivalent pure julia package is currently ModelingToolkit.jl

---

<div class="post-metadata">

**Author:** ![Luapulu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luapulu/32/17669_2.png) [@Luapulu](https://discourse.julialang.org/u/Luapulu)\
**Post date:** [February 26, 2021, 8:26am UTC](https://discourse.julialang.org/t/packages-for-latex-templating-in-julia-and-symbolic-algebra/55923/5 "2021-02-26T08:26:56Z")

</div>

Oops, jup. I got confused. With Reduce, SymPy, ModelingToolkit, SymEngine and more, there are quite a few options at this point.
