Tex_file_writing¶
manimlib/utils/tex_file_writing.py
这个文件中主要包含了将tex字符串使用LaTeX编译成svg的函数
-
manimlib.utils.tex_file_writing.
get_tex_config
() → dict¶ Returns a dict which should look something like this:
{ "executable": "latex", "template_file": "tex_template.tex", "intermediate_filetype": "dvi", "text_to_replace": "YourTextHere", "tex_body": "..." }
从 custom_defaults.yml
或 default_config.yml
中读取 tex 有关的配置
-
manimlib.utils.tex_file_writing.
tex_hash
(tex_file_content: str) → int¶
返回将 expression
和 template_tex_file_body
合并后sha256后的哈希值
-
manimlib.utils.tex_file_writing.
tex_to_svg_file
(tex_file_content: str) → str¶
将tex表达式转换为svg文件
(先写入.tex文件,再编译为.dvi/.xdv文件,后转换为.svg文件)
-
manimlib.utils.tex_file_writing.
tex_to_svg
(tex_file_content: str, svg_file: str) → str¶
将 tex 表达式内容转为 svg 文件
-
manimlib.utils.tex_file_writing.
tex_to_dvi
(tex_file: str) → str¶
将tex文件编译为dvi/xdv文件,并返回dvi/xdv文件
若
TEX_USE_CTEX=False
,则使用latex将tex编译为dvi若
TEX_USE_CTEX=True
,则使用xelatex将tex编译为xdv
-
manimlib.utils.tex_file_writing.
dvi_to_svg
(dvi_file: str) → str¶ Converts a dvi, which potentially has multiple slides, into a directory full of enumerated pngs corresponding with these slides. Returns a list of PIL Image objects for these images sorted as they where in the dvi
使用 dvisvgm 将 dvi/xdv 文件转换为 svg 文件,并返回 svg 文件