Skip to content

Commit 0826208

Browse files
authored
Merge pull request #1 from PhilippImhof/pr-483
Pr 483
2 parents eadeb3e + 36e5ae7 commit 0826208

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

manim/utils/tex.py

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,26 +97,75 @@ def rebuild(self):
9797
)
9898

9999
def prepend_to_preamble(self, txt):
100-
"""Adds txt to the TeX template preamble just after the \documentclass"""
100+
"""Adds txt to the TeX template preamble just after the \documentclass
101+
102+
Parameters
103+
----------
104+
txt : :class:`str`
105+
String containing the text to be added, e.g. ``\\usepackage{siunitx}``
106+
Returns
107+
-------
108+
None
109+
"""
101110
self.preamble = txt + "\n" + self.preamble
102111
self.rebuild()
103112

104113
def add_to_preamble(self, txt):
105-
"""Adds txt to the TeX template preamble just before \begin{document}"""
114+
"""Adds txt to the TeX template preamble just before \begin{document}
115+
116+
Parameters
117+
----------
118+
txt : :class:`str`
119+
String containing the text to be added, e.g. ``\\usepackage{hyperref}``
120+
Returns
121+
-------
122+
None
123+
"""
106124
self.preamble += "\n" + txt
107125
self.rebuild()
108126

109127
def add_to_document(self, txt):
110-
"""Adds txt to the TeX template just after \begin{document}"""
128+
"""Adds txt to the TeX template just after \begin{document}
129+
130+
Parameters
131+
----------
132+
txt : :class:`str`
133+
String containing the text to be added.
134+
Returns
135+
-------
136+
None
137+
"""
111138
self.post_doc_commands += "\n" + txt + "\n"
112139
self.rebuild()
113140

114141
def get_texcode_for_expression(self, expression):
115-
"""Inserts expression verbatim into TeX template."""
142+
"""Inserts expression verbatim into TeX template.
143+
144+
Parameters
145+
----------
146+
expression : :class:`str`
147+
The string containing the expression to be typeset, e.g. ``$\\sqrt{2}$``
148+
Returns
149+
-------
150+
:class:`str`
151+
LaTeX code based on template, containing the given expression and ready for typesetting
152+
"""
116153
return self.body.replace(self.placeholder_text, expression)
117154

118155
def get_texcode_for_expression_in_env(self, expression, environment):
119-
"""Inserts expression into TeX template wrapped in \begin{environemnt} and \end{environment}"""
156+
"""Inserts expression into TeX template wrapped in \begin{environemnt} and \end{environment}
157+
158+
Parameters
159+
----------
160+
expression : :class:`str`
161+
The string containing the expression to be typeset, e.g. ``$\\sqrt{2}$``
162+
environment : :class:`str`
163+
The string containing the environment in which the expression should be typeset, e.g. ``align*``
164+
Returns
165+
-------
166+
:class:`str`
167+
LaTeX code based on template, containing the given expression inside its environment, ready for typesetting
168+
"""
120169
begin = r"\begin{" + environment + "}"
121170
end = r"\end{" + environment + "}"
122171
return self.body.replace(

0 commit comments

Comments
 (0)