MCPcopy
hub / github.com/ManimCommunity/manim / get_texcode_for_expression_in_env

Method get_texcode_for_expression_in_env

manim/utils/tex.py:144–164  ·  view source on GitHub ↗

r"""Inserts expression into TeX template wrapped in ``\begin{environment}`` and ``\end{environment}``. Parameters ---------- expression The string containing the expression to be typeset, e.g. ``$\sqrt{2}$``. environment The string containing

(
        self, expression: str, environment: str
    )

Source from the content-addressed store, hash-verified

142 return self.body.replace(self.placeholder_text, expression)
143
144 def get_texcode_for_expression_in_env(
145 self, expression: str, environment: str
146 ) -> str:
147 r"""Inserts expression into TeX template wrapped in ``\begin{environment}`` and ``\end{environment}``.
148
149 Parameters
150 ----------
151 expression
152 The string containing the expression to be typeset, e.g. ``$\sqrt{2}$``.
153 environment
154 The string containing the environment in which the expression should be typeset, e.g. ``align*``.
155
156 Returns
157 -------
158 :class:`str`
159 LaTeX code based on template, containing the given expression inside its environment, ready for typesetting
160 """
161 begin, end = _texcode_for_environment(environment)
162 return self.body.replace(
163 self.placeholder_text, "\n".join([begin, expression, end])
164 )
165
166 def copy(self) -> Self:
167 """Create a deep copy of the TeX template instance."""

Calls 3

_texcode_for_environmentFunction · 0.85
replaceMethod · 0.45
joinMethod · 0.45