tex_file_writing

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

另请参阅

mobject.svg.tex_mobject

函数

compile_tex(tex_file, tex_compiler, output_format)[源代码]

将 TeX 文件编译为 .dvi、.xdv 或 .pdf 格式。

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

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

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

返回:

生成的目标格式(DVI、XDV 或 PDF)输出文件的路径。

返回类型:

Path

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

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

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

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

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

返回:

生成的 SVG 文件的路径。

返回类型:

Path

delete_nonsvg_files(additional_endings=())[源代码]

删除所有后缀不在 (".svg", ".tex", *additional_endings) 中的文件。

参数:

additional_endings (Iterable[str]) – 要列入白名单的其他后缀

返回类型:

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

接收一个 TeX 表达式(和一个可选的 TeX 环境),并返回一个完整的 TeX 文件,可供编译。

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

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

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

返回:

生成的 TeX 文件的路径

返回类型:

Path

insight_inputenc_error(matching)[源代码]
参数:

matching (Match[str])

返回类型:

Generator[str]

insight_package_not_found_error(matching)[源代码]
参数:

matching (Match[str])

返回类型:

Generator[str]

make_tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir)[源代码]

准备 TeX 编译命令,即 TeX 编译器名称和所有必要的 CLI 标志。

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

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

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

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

返回:

根据给定参数的编译命令

返回类型:

list[str]

print_all_tex_errors(log_file, tex_compiler, tex_file)[源代码]
参数:
  • log_file (Path)

  • tex_compiler (str)

  • tex_file (Path)

返回类型:

print_tex_error(tex_compilation_log, error_start_index, tex_source)[源代码]
参数:
  • tex_compilation_log (Sequence[str])

  • error_start_index (int)

  • tex_source (Sequence[str])

返回类型:

tex_hash(expression)[源代码]
参数:

expression (Any)

返回类型:

str

tex_to_svg_file(expression, environment=None, tex_template=None)[源代码]

接收一个 TeX 表达式,并返回编译后 TeX 的 SVG 版本。

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

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

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

返回:

生成的 SVG 文件的路径。

返回类型:

Path