Skip to content

Commit d41f00f

Browse files
author
Aron Fischer
committed
just one add_to_preamble method
1 parent 23edb7c commit d41f00f

File tree

2 files changed

+62
-69
lines changed

2 files changed

+62
-69
lines changed

manim/utils/tex.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,19 @@ def rebuild(self):
9595
+ "\n"
9696
)
9797

98-
def prepend_to_preamble(self, txt):
99-
"""Adds txt to the TeX template preamble just after the \documentclass
100-
101-
Parameters
102-
----------
103-
txt : :class:`str`
104-
String containing the text to be added, e.g. ``\\usepackage{siunitx}``
105-
"""
106-
self.preamble = txt + "\n" + self.preamble
107-
self.rebuild()
108-
109-
def add_to_preamble(self, txt):
110-
"""Adds txt to the TeX template preamble just before \\begin{document}
111-
98+
def add_to_preamble(self, txt, prepend=False):
99+
"""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.
112100
Parameters
113101
----------
114102
txt : :class:`str`
115103
String containing the text to be added, e.g. ``\\usepackage{hyperref}``
104+
prepend : Optional[:class:`bool`], optional
105+
Whether the text should be added at the beginning of the preample, i.e. right after ``\\documentclass``. Default is to add it at the end of the preample, i.e. right before ``\\begin{document}``
116106
"""
117-
self.preamble += "\n" + txt
107+
if prepend:
108+
self.preamble = txt + "\n" + self.preamble
109+
else:
110+
self.preamble += "\n" + txt
118111
self.rebuild()
119112

120113
def add_to_document(self, txt):

0 commit comments

Comments
 (0)