python宏包latex_Python latex包_程序模块 - PyPI - Python中文网

允许从python调用latex而不留下混乱。类似于

(正式过时)tex包,其

successor不能安装pypi:min_latex=(r"\documentclass{article}"r"\begin{document}"r"Hello, world!"r"\end{document}")fromlateximportbuild_pdf# this builds a pdf-file inside a temporary directorypdf=build_pdf(min_latex)# look at the first few bytes of the headerprintbytes(pdf)[:10]

还支持使用Jinja2模板

生成乳胶文件。

make_env可以用来创建一个Environment,它可以很好地与

乳胶:Variables can be used in a LaTeX friendly way: Hello, \VAR{name|e}.

Note that autoescaping is off. Blocks are creating using the block macro:

\BLOCK{if weather is 'good'}

Hooray.

\BLOCK{endif}

\#{comments are supported as well}

%# and so are line comments

To keep things short, line statements can be used:

%- if weather is good

Yay.

%- endif

示例使用fromjinja2.loadersimportFileSystemLoaderfromlatex.jinja2importmake_envenv=make_env(loader=FileSystemLoader('.'))tpl=env.get_template('doc.latex')print(tpl.render(name="Alice"))

base.latex演示如何用\BLOCK{...}替换

{% ... %}:\documentclass{article}\begin{document}\BLOCK{block body}\BLOCK{endblock}\end{document}

最后,doc.latex显示了为什么%-语法通常更可取:%- extends "base.latex"%- block bodyHello, \VAR{name|e}.

%- endblock

欢迎加入QQ群-->: 979659372

推荐PyPI第三方库

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值