Skip to main content

A simple template based doc generator

Project description

Templating with LaTex and Python

This year I'm trying to generate quizzes automatically to the degree possible.

I've cooked up a templating scheme using jijna2 that works with LaTeX templates.

This article was very helpful.

Now that this has been published to pypi you can simply:

pip install genlatex

Once you have that, you can 'cd' to the directory with your template and data generator file and run getlatex using:

genlatex [ options ] dataGeneratorFile.py

For example to create 10 versions of the example you could:

cd example

genlatex -n 10 tlo-EX-Data.py

Then check in the folder for your .tex files!

To convert to pdf en-masse, with bash:

find *.tex |  xargs -n 1 pdflatex

If your dataGeneratorFile needs to import any modules you should add '.' to the PYTHONPATH, e.g.,

PYTHONPATH=. genlatex -n 10 tlo-EX-Data.py

There is a shell script "buildZip.sh" that creates an importable .zip file that can be used to import quizzes into Sakai. It may also work for other LMS variations. Untested!

Update: Now you can run the full docker (Dockerfile-w-latex) version:

docker run --rm -it -v `pwd`:/work/src genlatex-full doExport.sh -n 10 tlo-EX-Data.py

Or the mini-docker (Dockerfile)

docker run --rm -it -v `pwd`:/work/src genlatex buildTeXs.sh -n 10 tlo-EX-Data.py

to build the mini-docker (without a full LaTeX install ~1.4GB)

docker build -t genlatex .

to build the full docker build (with a full LaTeX install ~7GB)

docker build -f Dockerfile-w-latex -t genlatex-full .

CHANGES:

v 0.12: Added units to formatters (e.g., latex_float(2.31, units="m"))

v 0.14: add units to latex_float and latex_vec, add some doc tests.

v 0.15: Changed the path handling to make it more Windows friendly.

v 0.16: Update README & other doc-strings

v 0.17: Add file path to items.xml so export.zip would contain individual filenames for students/instructors.

v 0.18: Possible breaking change. latex_float arguments are switching order, units first to save typing.
        Now you can type simply: latex_float(2.31,"m") and "m" will be units. If you want a different format
        then 'fmt' must be supplied as a *third* argument, or with a keyword, e.g. latex_float(2.234, fmt="{:0.2g}").

        Also, added a '-0' detector that should convert these to '0'.

v 0.19: Modified the attachment file paths so that Canvas would accept them. Unfortunately canvas does not
  	    support file upload questions in their current quiz tool.

v 0.20: Added eunit formatter to use "engineering" units.

v 0.24: Various changes, includeing command line variables in templates.

v 0.25: Force wheel in pypi

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genlatex-0.25.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

genlatex-0.25-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file genlatex-0.25.tar.gz.

File metadata

  • Download URL: genlatex-0.25.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.5

File hashes

Hashes for genlatex-0.25.tar.gz
Algorithm Hash digest
SHA256 05d1a338bcb77ce8ed779492e3ccce1ead8a9293ede956c932bdc6f46a0b3e2c
MD5 30c2fffbeb79fba5ed727da69d8c16ad
BLAKE2b-256 69462a4a0ad01f47e4ed1f37ea9fb03e14647c8b00f9e10390685ad8c974e051

See more details on using hashes here.

File details

Details for the file genlatex-0.25-py3-none-any.whl.

File metadata

  • Download URL: genlatex-0.25-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.5

File hashes

Hashes for genlatex-0.25-py3-none-any.whl
Algorithm Hash digest
SHA256 4bdcd25921115cd3bebc8e3099e2fd80e872785af8c3a0203e3ae2866bd32618
MD5 f2f0487663166b84f96023a1e03a191b
BLAKE2b-256 35a8dd210fc562508621a805b3be3551b4368283bd8404fd28aa37d65ec9b875

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page