基于简单模板的文档生成器
项目描述
使用LaTeX和Python进行模板化
今年我尝试尽可能自动生成测验。
我制定了一个使用jijna2的模板方案,它与LaTeX模板一起工作。
这篇文章非常有帮助。
现在这个已经发布到pypi上,您可以简单地
pip install genlatex
一旦您有了它,您就可以使用以下命令在模板和数据生成器文件所在的目录中运行getlatex
genlatex [ options ] dataGeneratorFile.py
例如,要创建10个示例版本,您可以
cd example
genlatex -n 10 tlo-EX-Data.py
然后检查文件夹中的.tex文件!
使用bash批量转换为pdf
find *.tex | xargs -n 1 pdflatex
如果您的dataGeneratorFile需要导入任何模块,您应该在PYTHONPATH中添加'.',例如
PYTHONPATH=. genlatex -n 10 tlo-EX-Data.py
有一个shell脚本"buildZip.sh",它可以创建一个可导入的.zip文件,用于将测验导入Sakai。它也可能适用于其他LMS变体。未测试!
更新:现在您可以运行完整的docker(Dockerfile-w-latex)版本
docker run --rm -it -v `pwd`:/work/src genlatex-full doExport.sh -n 10 tlo-EX-Data.py
或者迷你docker(Dockerfile)
docker run --rm -it -v `pwd`:/work/src genlatex buildTeXs.sh -n 10 tlo-EX-Data.py
构建迷你docker(无需完整的LaTeX安装 ~1.4GB)
docker build -t genlatex .
构建带有完整LaTeX安装的完整docker构建(~7GB)
docker build -f Dockerfile-w-latex -t genlatex-full .
变更
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
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。
源分发
genlatex-0.25.tar.gz (6.9 kB 查看哈希值)
构建分发
genlatex-0.25-py3-none-any.whl (7.8 kB 查看哈希值)