tex_file_writing#
Interface for writing, compiling, and converting .tex
files.
See also
mobject.svg.tex_mobject
Functions
- compile_tex(tex_file, tex_compiler, output_format)[source]#
Compiles a tex_file into a .dvi or a .xdv or a .pdf
- Parameters
tex_file (
str
) – File name of TeX file to be typeset.tex_compiler (
str
) – String containing the compiler to be used, e.g.pdflatex
orlualatex
output_format (
str
) – String containing the output format generated by the compiler, e.g..dvi
or.pdf
- Returns
Path to generated output file in desired format (DVI, XDV or PDF).
- Return type
str
- convert_to_svg(dvi_file, extension, page=1)[source]#
Converts a .dvi, .xdv, or .pdf file into an svg using dvisvgm.
- Parameters
dvi_file (
str
) – File name of the input file to be converted.extension (
str
) – String containing the file extension and thus indicating the file type, e.g..dvi
or.pdf
page (Optional[
int
], optional) – Page to be converted if input file is multi-page.
- Returns
Path to generated SVG file.
- Return type
str
- generate_tex_file(expression, environment=None, tex_template=None)[source]#
Takes a tex expression (and an optional tex environment), and returns a fully formed tex file ready for compilation.
- Parameters
expression (
str
) – String containing the TeX expression to be rendered, e.g.\sqrt{2}
orfoo
environment (Optional[
str
], optional) – The string containing the environment in which the expression should be typeset, e.g.align*
tex_template (Optional[
TexTemplate
], optional) – Template class used to typesetting. If not set, use default template set via config[“tex_template”]
- Returns
Path to generated TeX file
- Return type
str
- tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir)[source]#
Prepares the tex compilation command with all necessary cli flags
- Parameters
tex_compiler (
str
) – String containing the compiler to be used, e.g.pdflatex
orlualatex
output_format (
str
) – String containing the output format generated by the compiler, e.g..dvi
or.pdf
tex_file (
str
) – File name of TeX file to be typeset.tex_dir (
str
) – Path to the directory where compiler output will be stored.
- Returns
Compilation command according to given parameters
- Return type
str
- tex_to_svg_file(expression, environment=None, tex_template=None)[source]#
Takes a tex expression and returns the svg version of the compiled tex
- Parameters
expression (
str
) – String containing the TeX expression to be rendered, e.g.\sqrt{2}
orfoo
environment (Optional[
str
], optional) – The string containing the environment in which the expression should be typeset, e.g.align*
tex_template (Optional[
TexTemplate
], optional) – Template class used to typesetting. If not set, use default template set via config[“tex_template”]
- Returns
Path to generated SVG file.
- Return type
str