tex文件编写

用于编写、编译和转换.tex文件的接口。

另请参阅

mobject.svg.tex_mobject

函数

compile_tex(tex_file, tex_compiler, output_format)[source]

将tex_file编译为.dvi、.xdv或.pdf文件

Parameters:
  • tex_file (Path) – 要排版的TeX文件的文件名。

  • tex_compiler (str) – 包含要使用的编译器的字符串,例如 pdflatexlualatex

  • output_format (str) – 包含编译器生成的输出格式的字符串,例如 .dvi.pdf

Returns:

生成输出文件的路径,格式为所需的格式(DVI、XDV 或 PDF)。

Return type:

路径

convert_to_svg(dvi_file, extension, page=1)[来源]

使用dvisvgm将.dvi、.xdv或.pdf文件转换为svg。

Parameters:
  • dvi_file (Path) – 要转换的输入文件的文件名。

  • extension (str) – 包含文件扩展名的字符串,从而指示文件类型,例如 .dvi.pdf

  • page (int) – 如果输入文件是多页的,则要转换的页面。

Returns:

生成的SVG文件的路径。

Return type:

路径

delete_nonsvg_files(additional_endings=())[来源]

删除没有后缀在(".svg", ".tex", *additional_endings)中的每个文件

Parameters:

additional_endings (Iterable[str]) – 要加入白名单的额外结尾

Return type:

generate_tex_file(expression, environment=None, tex_template=None)[来源]

接受一个tex表达式(以及一个可选的tex环境),并返回一个准备编译的完整tex文件。

Parameters:
  • expression (str) – 包含要渲染的TeX表达式的字符串,例如 \sqrt{2}foo

  • 环境 (str | None) – 包含表达式应排版的环境的字符串,例如 align*

  • tex_template (TexTemplate | None) – 用于排版的模板类。如果未设置,则使用通过config[“tex_template”]设置的默认模板。

Returns:

生成的TeX文件路径

Return type:

路径

insight_inputenc_error(matching)[来源]
insight_package_not_found_error(matching)[来源]
print_all_tex_errors(log_file, tex_compiler, tex_file)[source]
Parameters:
  • log_file (路径)

  • tex_compiler (str)

  • tex_file (路径)

Return type:

print_tex_error(tex_compilation_log, error_start_index, tex_source)[来源]
tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir)[source]

准备带有所有必要命令行标志的tex编译命令

Parameters:
  • tex_compiler (str) – 包含要使用的编译器的字符串,例如 pdflatexlualatex

  • output_format (str) – 包含编译器生成的输出格式的字符串,例如 .dvi.pdf

  • tex_file (Path) – 要排版的TeX文件的文件名。

  • tex_dir (Path) – 编译器输出将存储的目录路径。

Returns:

根据给定参数的编译命令

Return type:

str

tex_hash(expression)[source]
tex_to_svg_file(expression, environment=None, tex_template=None)[来源]

接受一个tex表达式并返回编译后的tex的svg版本

Parameters:
  • expression (str) – 包含要渲染的TeX表达式的字符串,例如 \sqrt{2}foo

  • 环境 (str | None) – 包含表达式应排版的环境的字符串,例如 align*

  • tex_template (TexTemplate | None) – 用于排版的模板类。如果未设置,则使用通过config[“tex_template”]设置的默认模板。

Returns:

生成的SVG文件的路径。

Return type:

路径