TexTemplate#

Qualified name: manim.utils.tex.TexTemplate

class TexTemplate(tex_compiler=None, output_format=None, documentclass=None, preamble=None, placeholder_text=None, post_doc_commands=None, **kwargs)[source]#

Bases: object

TeX templates are used for creating Tex() and MathTex() objects.

Parameters:
  • tex_compiler (str | None) – The TeX compiler to be used, e.g. latex, pdflatex or lualatex

  • output_format (str | None) – The output format resulting from compilation, e.g. .dvi or .pdf

  • documentclass (str | None) – The command defining the documentclass, e.g. \documentclass[preview]{standalone}

  • preamble (str | None) – The document’s preamble, i.e. the part between \documentclass and \begin{document}

  • placeholder_text (str | None) – Text in the document that will be replaced by the expression to be rendered

  • post_doc_commands (str | None) – Text (definitions, commands) to be inserted at right after \begin{document}, e.g. \boldmath

tex_compiler#

The TeX compiler to be used, e.g. latex, pdflatex or lualatex

Type:

str

output_format#

The output format resulting from compilation, e.g. .dvi or .pdf

Type:

str

documentclass#

The command defining the documentclass, e.g. \documentclass[preview]{standalone}

Type:

str

preamble#

The document’s preamble, i.e. the part between \documentclass and \begin{document}

Type:

str

placeholder_text#

Text in the document that will be replaced by the expression to be rendered

Type:

str

post_doc_commands#

Text (definitions, commands) to be inserted at right after \begin{document}, e.g. \boldmath

Type:

str

Methods

add_to_document

Adds txt to the TeX template just after begin{document}, e.g.

add_to_preamble

Adds stuff to the TeX template's preamble (e.g.

copy

get_texcode_for_expression

Inserts expression verbatim into TeX template.

get_texcode_for_expression_in_env

Inserts expression into TeX template wrapped in begin{environment} and end{environment}

Attributes

default_documentclass

default_output_format

default_placeholder_text

default_post_doc_commands

default_preamble

default_tex_compiler

_rebuild()[source]#

Rebuilds the entire TeX template text from \documentclass to \end{document} according to all settings and choices.

_texcode_for_environment(environment)[source]#

Processes the tex_environment string to return the correct \begin{environment}[extra]{extra} and \end{environment} strings

Parameters:

environment (str) – The tex_environment as a string. Acceptable formats include: {align*}, align*, {tabular}[t]{cccl}, tabular}{cccl, \begin{tabular}[t]{cccl}.

Returns:

A pair of strings representing the opening and closing of the tex environment, e.g. \begin{tabular}{cccl} and \end{tabular}

Return type:

Tuple[str, str]

add_to_document(txt)[source]#

Adds txt to the TeX template just after begin{document}, e.g. \boldmath

Parameters:

txt (str) – String containing the text to be added.

add_to_preamble(txt, prepend=False)[source]#

Adds stuff to the TeX template’s preamble (e.g. definitions, packages). Text can be inserted at the beginning or at the end of the preamble.

Parameters:
  • txt (str) – String containing the text to be added, e.g. \usepackage{hyperref}

  • prepend (bool) – Whether the text should be added at the beginning of the preamble, i.e. right after \documentclass. Default is to add it at the end of the preamble, i.e. right before \begin{document}

get_texcode_for_expression(expression)[source]#

Inserts expression verbatim into TeX template.

Parameters:

expression (str) – The string containing the expression to be typeset, e.g. $\sqrt{2}$

Returns:

LaTeX code based on current template, containing the given expression and ready for typesetting

Return type:

str

get_texcode_for_expression_in_env(expression, environment)[source]#

Inserts expression into TeX template wrapped in begin{environment} and end{environment}

Parameters:
  • expression (str) – The string containing the expression to be typeset, e.g. $\\sqrt{2}$

  • environment (str) – The string containing the environment in which the expression should be typeset, e.g. align*

Returns:

LaTeX code based on template, containing the given expression inside its environment, ready for typesetting

Return type:

str