TexTemplate¶
Qualified name: manim.utils.tex.TexTemplate
- class TexTemplate(tex_compiler='latex', description='', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}', placeholder_text='YourTextHere', post_doc_commands='')[source]¶
Bases:
objectTeX templates are used to create
TexandMathTexobjects.Methods
Adds text to the TeX template just after begin{document}, e.g.
\boldmath.Adds text to the TeX template's preamble (e.g. definitions, packages).
Create a deep copy of the TeX template instance.
Create an instance by reading the content of a file.
Inserts expression verbatim into TeX template.
Inserts expression into TeX template wrapped in
\begin{environment}and\end{environment}.Attributes
The entire TeX template.
A description of the template
The command defining the documentclass, e.g.
\documentclass[preview]{standalone}.The output format resulting from compilation, e.g.
.dvior.pdf.Text in the document that will be replaced by the expression to be rendered.
Text (definitions, commands) to be inserted at right after
\begin{document}, e.g.\boldmath.The document's preamble, i.e. the part between
\documentclassand\begin{document}.The TeX compiler to be used, e.g.
latex,pdflatexorlualatex.- Parameters:
tex_compiler (str)
description (str)
output_format (str)
documentclass (str)
preamble (str)
placeholder_text (str)
post_doc_commands (str)
- _body: str = ''¶
A custom body, can be set from a file.
- add_to_document(txt)[source]¶
Adds text to the TeX template just after begin{document}, e.g.
\boldmath.- Parameters:
txt (str) – String containing the text to be added.
- Return type:
Self
- add_to_preamble(txt, prepend=False)[source]¶
Adds text 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}.
- Return type:
Self
- property body: str¶
The entire TeX template.
- description: str = ''¶
A description of the template
- documentclass: str = '\\documentclass[preview]{standalone}'¶
The command defining the documentclass, e.g.
\documentclass[preview]{standalone}.
- classmethod from_file(file='tex_template.tex', **kwargs)[source]¶
Create an instance by reading the content of a file.
Using the
add_to_preambleandadd_to_documentmethods on this instance will have no effect, as the body is read from the file.- Parameters:
file (StrPath)
kwargs (Any)
- Return type:
Self
- 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
expressionand 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
- output_format: str = '.dvi'¶
The output format resulting from compilation, e.g.
.dvior.pdf.
- placeholder_text: str = 'YourTextHere'¶
Text in the document that will be replaced by the expression to be rendered.
- post_doc_commands: str = ''¶
Text (definitions, commands) to be inserted at right after
\begin{document}, e.g.\boldmath.
- preamble: str = '\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}'¶
The document’s preamble, i.e. the part between
\documentclassand\begin{document}.
- tex_compiler: str = 'latex'¶
The TeX compiler to be used, e.g.
latex,pdflatexorlualatex.