API 参考:工具(utils)¶
共 8 个类,按字母排序。每个类含中文说明、继承链、参数表与上手示例,API 文档由 autodoc 从 manim v0.21.0 源码自动生成;带完整中文精讲的类见 API 索引。
DictAsObject¶
把字典包成属性访问的小工具类:d.key 替代 d[键],配置读取更便捷。
参数¶
API 文档¶
- class manim.DictAsObject(dictin: dict[str, Any])¶
基类:
object
HSV¶
HSV 颜色:色相/饱和度/明度三元组,做色轮、渐变等色彩动画用。
继承关系¶
参数¶
|
— |
|---|---|
|
1.0,float |
API 文档¶
- class manim.HSV(hsv: NDArray[float64] | tuple[float, float, float] | tuple[float, float, float, float], alpha: float = 1.0)¶
基类:
ManimColor
ManimColor¶
v0.19 起的新颜色基类:RGB(A) 统一封装,hex/HSV/内置色互转,颜色运算的中枢。
参数¶
|
— |
|---|---|
|
1.0,float |
快速上手¶
c = ManimColor("#FFFF00").interpolate(BLUE, 0.5)
API 文档¶
- class manim.ManimColor(value: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | None, alpha: float = 1.0)¶
基类:
object- contrasting(threshold: float = 0.5, light: Self | None = None, dark: Self | None = None) Self¶
Return one of two colors, light or dark (by default white or black), that contrasts with the current color (depending on its luminance). This is typically used to set text in a contrasting color that ensures it is readable against a background of the current color.
Parameters¶
- threshold
The luminance threshold which dictates whether the current color is considered light or dark (and thus whether to return the dark or light color, respectively). Default is 0.5.
- light
The light color to return if the current color is considered dark. Default is
None: in this case, pureWHITEwill be returned.- dark
The dark color to return if the current color is considered light, Default is
None: in this case, pureBLACKwill be returned.
Returns¶
- ManimColor
The contrasting
ManimColor.
- darker(blend: float = 0.2) Self¶
Return a new color that is darker than the current color, i.e. interpolated with
BLACK. The opacity is unchanged.Parameters¶
- blend
The blend ratio for the interpolation, from 0.0 (the current color unchanged) to 1.0 (pure black). Default is 0.2, which results in a slightly darker color.
Returns¶
- ManimColor
The darker
ManimColor.
See Also¶
- classmethod from_hex(hex_str: str, alpha: float = 1.0) Self¶
Create a
ManimColorfrom a hex string.Parameters¶
- hex_str
The hex string to be converted. The allowed prefixes for this string are
#and0x. Currently, this method only supports 6 nibbles, i.e. only strings in the format#XXXXXXor0xXXXXXX.- alpha
Alpha value to be used for the hex string. Default is 1.0.
Returns¶
- ManimColor
The
ManimColorrepresented by the hex string.
- classmethod from_hsl(hsl: NDArray[float64] | tuple[float, float, float], alpha: float = 1.0) Self¶
Create a
ManimColorfrom an HSL array.Parameters¶
- hsl
Any iterable containing 3 floats from 0.0 to 1.0.
- alpha
The alpha value to be used. Default is 1.0.
Returns¶
- ManimColor
The
ManimColorwith the corresponding RGB values to the given HSL array.
- classmethod from_hsv(hsv: NDArray[float64] | tuple[float, float, float], alpha: float = 1.0) Self¶
Create a
ManimColorfrom an HSV array.Parameters¶
- hsv
Any iterable containing 3 floats from 0.0 to 1.0.
- alpha
The alpha value to be used. Default is 1.0.
Returns¶
- ManimColor
The
ManimColorwith the corresponding RGB values to the given HSV array.
- classmethod from_rgb(rgb: NDArray[float64] | tuple[float, float, float] | NDArray[int64] | tuple[int, int, int], alpha: float = 1.0) Self¶
Create a ManimColor from an RGB array. Automagically decides which type it is:
intorfloat.警告
Please make sure that your elements are not floats if you want integers. A
5.0will result in the input being interpreted as if it was an RGB float array with the value5.0and not the integer5.Parameters¶
- rgb
Any iterable of 3 floats or 3 integers.
- alpha
Alpha value to be used in the color. Default is 1.0.
Returns¶
- ManimColor
The
ManimColorwhich corresponds to the givenrgb.
- classmethod from_rgba(rgba: NDArray[float64] | tuple[float, float, float, float] | NDArray[int64] | tuple[int, int, int, int]) Self¶
Create a ManimColor from an RGBA Array. Automagically decides which type it is:
intorfloat.警告
Please make sure that your elements are not floats if you want integers. A
5.0will result in the input being interpreted as if it was a float RGB array with the float5.0and not the integer5.Parameters¶
- rgba
Any iterable of 4 floats or 4 integers.
Returns¶
- ManimColor
The
ManimColorcorresponding to the givenrgba.
- static gradient(colors: list[ManimColor], length: int) ManimColor | list[ManimColor]¶
This method is currently not implemented. Refer to
color_gradient()for a working implementation for now.
- interpolate(other: Self, alpha: float) Self¶
Interpolate between the current and the given
ManimColor, and return the result.Parameters¶
- other
The other
ManimColorto be used for interpolation.- alpha
A point on the line in RGBA colorspace connecting the two colors, i.e. the interpolation point. 0.0 corresponds to the current
ManimColorand 1.0 corresponds to the otherManimColor.
Returns¶
- ManimColor
The interpolated
ManimColor.
- into(class_type: type[ManimColorT]) ManimColorT¶
Convert the current color into a different colorspace given by
class_type, without changing the_internal_value.Parameters¶
- class_type
The class that is used for conversion. It must be a subclass of
ManimColorwhich respects the specification HSV, RGBA, ...
Returns¶
- ManimColorT
A new color object of type
class_typeand the same_internal_valueas the original color.
- invert(with_alpha: bool = False) Self¶
Return a new, linearly inverted version of this
ManimColor(no inplace changes).Parameters¶
- with_alpha
If
True, the alpha value will be inverted too. Default isFalse.备注
Setting
with_alpha=Truecan result in unintended behavior where objects are not displayed because their new alpha value is suddenly 0 or very low.
Returns¶
- ManimColor
The linearly inverted
ManimColor.
- lighter(blend: float = 0.2) Self¶
Return a new color that is lighter than the current color, i.e. interpolated with
WHITE. The opacity is unchanged.Parameters¶
- blend
The blend ratio for the interpolation, from 0.0 (the current color unchanged) to 1.0 (pure white). Default is 0.2, which results in a slightly lighter color.
Returns¶
- ManimColor
The lighter
ManimColor.
See Also¶
- opacity(opacity: float) Self¶
Create a new
ManimColorwith the given opacity and the same color values as before.Parameters¶
- opacity
The new opacity value to be used.
Returns¶
- ManimColor
The new
ManimColorwith the same color values and the new opacity.
- classmethod parse(color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | None, alpha: float = 1.0) Self¶
- classmethod parse(color: Sequence[ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float]], alpha: float = 1.0) list[Self]
Parse one color as a
ManimColoror a sequence of colors as a list ofManimColor's.Parameters¶
- color
The color or list of colors to parse. Note that this function can not accept tuples: it will assume that you mean
Sequence[ParsableManimColor]and will return alist[ManimColor].- alpha
The alpha (opacity) value to use for the passed color(s).
Returns¶
- ManimColor | list[ManimColor]
Either a list of colors or a singular color, depending on the input.
- to_hex(with_alpha: bool = False) str¶
Convert the
ManimColorto a hexadecimal representation of the color.Parameters¶
- with_alpha
If
True, append 2 extra characters to the hex string which represent the alpha value of the color between 0 and 255. Default isFalse.
Returns¶
- str
A hex string starting with a
#, with either 6 or 8 nibbles depending on thewith_alphaparameter. By default, it has 6 nibbles, i.e.#XXXXXX.
- to_hsl() NDArray[float64]¶
Convert the
ManimColorto an HSL array.备注
Be careful: this returns an array in the form
[h, s, l], where the elements are floats. This might be confusing, because RGB can also be an array of floats. You might want to annotate the usage of this function in your code by typing your HSL array variables asHSL_Array_Floatin order to differentiate them from RGB arrays.Returns¶
- HSL_Array_Float
An HSL array of 3 floats from 0.0 to 1.0.
- to_hsv() NDArray[float64]¶
Convert the
ManimColorto an HSV array.备注
Be careful: this returns an array in the form
[h, s, v], where the elements are floats. This might be confusing, because RGB can also be an array of floats. You might want to annotate the usage of this function in your code by typing your HSV array variables asHSV_Array_Floatin order to differentiate them from RGB arrays.Returns¶
- HSV_Array_Float
An HSV array of 3 floats from 0.0 to 1.0.
- to_int_rgb() NDArray[int64]¶
Convert the current
ManimColorinto an RGB array of integers.Returns¶
- RGB_Array_Int
RGB array of 3 integers from 0 to 255.
- to_int_rgba() NDArray[int64]¶
Convert the current ManimColor into an RGBA array of integers.
Returns¶
- RGBA_Array_Int
RGBA array of 4 integers from 0 to 255.
- to_int_rgba_with_alpha(alpha: float) NDArray[int64]¶
Convert the current
ManimColorinto an RGBA array of integers. This is similar toto_int_rgba(), but you can change the alpha value.Parameters¶
- alpha
Alpha value to be used for the return value. Pass a float between 0.0 and 1.0: it will automatically be scaled to an integer between 0 and 255.
Returns¶
- RGBA_Array_Int
RGBA array of 4 integers from 0 to 255.
- to_integer() int¶
Convert the current
ManimColorinto an integer.警告
This will return only the RGB part of the color.
Returns¶
- int
Integer representation of the color.
- to_rgb() NDArray[float64]¶
Convert the current
ManimColorinto an RGB array of floats.Returns¶
- RGB_Array_Float
RGB array of 3 floats from 0.0 to 1.0.
- to_rgba() NDArray[float64]¶
Convert the current
ManimColorinto an RGBA array of floats.Returns¶
- RGBA_Array_Float
RGBA array of 4 floats from 0.0 to 1.0.
- to_rgba_with_alpha(alpha: float) NDArray[float64]¶
Convert the current
ManimColorinto an RGBA array of floats. This is similar toto_rgba(), but you can change the alpha value.Parameters¶
- alpha
Alpha value to be used in the return value.
Returns¶
- RGBA_Array_Float
RGBA array of 4 floats from 0.0 to 1.0.
RGBA¶
带透明度的颜色表示:r/g/b/a 四通道,ManimColor 的底层载体。
参数¶
|
— |
|---|---|
|
1.0,float |
API 文档¶
- manim.RGBA¶
ManimColor的别名
RandomColorGenerator¶
随机颜色生成器:按配色策略批量产色,做随机配色演示用。
参数¶
|
None,int | None |
|---|---|
|
None,list[ManimColor] | None |
API 文档¶
- class manim.RandomColorGenerator(seed: int | None = None, sample_colors: list[ManimColor] | None = None)¶
基类:
object- next() ManimColor¶
Returns the next color from the configured color list.
Returns¶
- ManimColor
A randomly selected color from the specified color list.
Examples¶
Usage:
>>> from manim import RandomColorGenerator, RED >>> rnd = RandomColorGenerator(sample_colors=[RED]) >>> rnd.next() ManimColor('#FC6255')
TexFontTemplates¶
Tex 字体模板集合:pdfLaTeX 各字体配置的现成模板。
API 文档¶
- class manim.TexFontTemplates¶
基类:
object- american_typewriter = TexTemplate(_body='', tex_compiler='xelatex', description='American Typewriter', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{American Typewriter}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
American Typewriter
- antykwa = TexTemplate(_body='', tex_compiler='latex', description='Antykwa Półtawskiego (TX Fonts for Greek and math symbols)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[OT4,OT1]{fontenc}\n\\usepackage{txfonts}\n\\usepackage[upright]{txgreeks}\n\\usepackage{antpolt}\n\\usepackage[defaultmathsizes,nolessnomore]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Antykwa Półtawskiego (TX Fonts for Greek and math symbols)
- apple_chancery = TexTemplate(_body='', tex_compiler='xelatex', description='Apple Chancery', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Apple Chancery}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Apple Chancery
- auriocus_kalligraphicus = TexTemplate(_body='', tex_compiler='latex', description='Auriocus Kalligraphicus (Symbol Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{aurical}\n\\renewcommand{\\rmdefault}{AuriocusKalligraphicus}\n\\usepackage[symbolgreek]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Auriocus Kalligraphicus (Symbol Greek)
- baskervald_adf_fourier = TexTemplate(_body='', tex_compiler='latex', description='Baskervald ADF with Fourier', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[upright]{fourier}\n\\usepackage{baskervald}\n\\usepackage[defaultmathsizes,noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Baskervald ADF with Fourier
- baskerville_it = TexTemplate(_body='', tex_compiler='xelatex', description='Baskerville (Italic)', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Baskerville}\n\\usepackage[defaultmathsizes,italic]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Baskerville (Italic)
- biolinum = TexTemplate(_body='', tex_compiler='latex', description='Biolinum', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{libertine}\n\\renewcommand{\\familydefault}{\\sfdefault}\n\\usepackage[greek=n,biolinum]{libgreek}\n\\usepackage[noasterisk,defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Biolinum
- brushscriptx = TexTemplate(_body='', tex_compiler='xelatex', description='BrushScriptX-Italic (PX math and Greek)', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{pxfonts}\n%\\usepackage{pbsi}\n\\renewcommand{\\rmdefault}{pbsi}\n\\renewcommand{\\mddefault}{xl}\n\\renewcommand{\\bfdefault}{xl}\n\\usepackage[defaultmathsizes,noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='\\boldmath\n')¶
BrushScriptX-Italic (PX math and Greek)
- chalkboard_se = TexTemplate(_body='', tex_compiler='xelatex', description='Chalkboard SE', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Chalkboard SE}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Chalkboard SE
- chalkduster = TexTemplate(_body='', tex_compiler='lualatex', description='Chalkduster', output_format='.pdf', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Chalkduster}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Chalkduster
- comfortaa = TexTemplate(_body='', tex_compiler='latex', description='Comfortaa', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[default]{comfortaa}\n\\usepackage[LGRgreek,defaultmathsizes,noasterisk]{mathastext}\n\\let\\varphi\\phi\n\\linespread{1.06}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Comfortaa
- comic_sans = TexTemplate(_body='', tex_compiler='xelatex', description='Comic Sans MS', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Comic Sans MS}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Comic Sans MS
- droid_sans = TexTemplate(_body='', tex_compiler='latex', description='Droid Sans', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[default]{droidsans}\n\\usepackage[LGRgreek]{mathastext}\n\\let\\varepsilon\\epsilon\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Droid Sans
- droid_sans_it = TexTemplate(_body='', tex_compiler='latex', description='Droid Sans (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[default]{droidsans}\n\\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}\n\\let\\varphi\\phi\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Droid Sans (Italic)
- droid_serif = TexTemplate(_body='', tex_compiler='latex', description='Droid Serif', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[default]{droidserif}\n\\usepackage[LGRgreek]{mathastext}\n\\let\\varepsilon\\epsilon\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Droid Serif
- droid_serif_px_it = TexTemplate(_body='', tex_compiler='latex', description='Droid Serif (PX math symbols) (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{pxfonts}\n\\usepackage[default]{droidserif}\n\\usepackage[LGRgreek,defaultmathsizes,italic,basic]{mathastext}\n\\let\\varphi\\phi\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Droid Serif (PX math symbols) (Italic)
- ecf_augie = TexTemplate(_body='', tex_compiler='latex', description='ECF Augie (Euler Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\renewcommand\\familydefault{fau} % emerald package\n\\usepackage[defaultmathsizes,eulergreek]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
ECF Augie (Euler Greek)
- ecf_jd = TexTemplate(_body='', tex_compiler='latex', description='ECF JD (with TX fonts)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{txfonts}\n\\usepackage[upright]{txgreeks}\n\\renewcommand\\familydefault{fjd} % emerald package\n\\usepackage{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='\\mathversion{bold}\n')¶
ECF JD (with TX fonts)
- ecf_skeetch = TexTemplate(_body='', tex_compiler='latex', description='ECF Skeetch (CM Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[T1]{fontenc}\n\\DeclareFontFamily{T1}{fsk}{}\n\\DeclareFontShape{T1}{fsk}{m}{n}{<->s*[1.315] fskmw8t}{}\n\\renewcommand\\rmdefault{fsk}\n\\usepackage[noendash,defaultmathsizes,nohbar,defaultimath]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
ECF Skeetch (CM Greek)
- ecf_tall_paul = TexTemplate(_body='', tex_compiler='latex', description='ECF Tall Paul (with Symbol font)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\DeclareFontFamily{T1}{ftp}{}\n\\DeclareFontShape{T1}{ftp}{m}{n}{\n <->s*[1.4] ftpmw8t\n}{} % increase size by factor 1.4\n\\renewcommand\\familydefault{ftp} % emerald package\n\\usepackage[symbol]{mathastext}\n\\let\\infty\\inftypsy\n', placeholder_text='YourTextHere', post_doc_commands='')¶
ECF Tall Paul (with Symbol font)
- ecf_webster = TexTemplate(_body='', tex_compiler='latex', description='ECF Webster (with TX fonts)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{txfonts}\n\\usepackage[upright]{txgreeks}\n\\renewcommand\\familydefault{fwb} % emerald package\n\\usepackage{mathastext}\n\\renewcommand{\\int}{\\intop\\limits}\n\\linespread{1.5}\n', placeholder_text='YourTextHere', post_doc_commands='\n\\mathversion{bold}\n')¶
ECF Webster (with TX fonts)
- electrum_adf = TexTemplate(_body='', tex_compiler='latex', description='Electrum ADF (CM Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[LGRgreek,basic,defaultmathsizes]{mathastext}\n\\usepackage[lf]{electrum}\n\\Mathastext\n\\let\\varphi\\phi\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Electrum ADF (CM Greek)
- epigrafica = TexTemplate(_body='', tex_compiler='latex', description='Epigrafica', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[LGR,OT1]{fontenc}\n\\usepackage{epigrafica}\n\\usepackage[basic,LGRgreek,defaultmathsizes]{mathastext}\n\\let\\varphi\\phi\n\\linespread{1.2}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Epigrafica
- fourier_utopia = TexTemplate(_body='', tex_compiler='latex', description='Fourier Utopia (Fourier upright Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[upright]{fourier}\n\\usepackage{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Fourier Utopia (Fourier upright Greek)
- french_cursive = TexTemplate(_body='', tex_compiler='latex', description='French Cursive (Euler Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[default]{frcursive}\n\\usepackage[eulergreek,noplusnominus,noequal,nohbar,%\nnolessnomore,noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
French Cursive (Euler Greek)
- gfs_bodoni = TexTemplate(_body='', tex_compiler='latex', description='GFS Bodoni', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\renewcommand{\\rmdefault}{bodoni}\n\\usepackage[LGRgreek]{mathastext}\n\\let\\varphi\\phi\n\\linespread{1.06}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
GFS Bodoni
- gfs_didot = TexTemplate(_body='', tex_compiler='latex', description='GFS Didot (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\renewcommand\\rmdefault{udidot}\n\\usepackage[LGRgreek,defaultmathsizes,italic]{mathastext}\n\\let\\varphi\\phi\n', placeholder_text='YourTextHere', post_doc_commands='')¶
GFS Didot (Italic)
- gfs_neoHellenic = TexTemplate(_body='', tex_compiler='latex', description='GFS NeoHellenic', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\renewcommand{\\rmdefault}{neohellenic}\n\\usepackage[LGRgreek]{mathastext}\n\\let\\varphi\\phi\n\\linespread{1.06}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
GFS NeoHellenic
- gnu_freesans_tx = TexTemplate(_body='', tex_compiler='xelatex', description='GNU FreeSerif (and TX fonts symbols)', output_format='.pdf', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\usepackage{txfonts} %\\let\\mathbb=\\varmathbb\n\\setmainfont[ExternalLocation,\n Mapping=tex-text,\n BoldFont=FreeSerifBold,\n ItalicFont=FreeSerifItalic,\n BoldItalicFont=FreeSerifBoldItalic]{FreeSerif}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
GNU FreeSerif (and TX fonts symbols)
- gnu_freeserif_freesans = TexTemplate(_body='', tex_compiler='xelatex', description='GNU FreeSerif and FreeSans', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble="\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[ExternalLocation,\n Mapping=tex-text,\n BoldFont=FreeSerifBold,\n ItalicFont=FreeSerifItalic,\n BoldItalicFont=FreeSerifBoldItalic]{FreeSerif}\n\\setsansfont[ExternalLocation,\n Mapping=tex-text,\n BoldFont=FreeSansBold,\n ItalicFont=FreeSansOblique,\n BoldItalicFont=FreeSansBoldOblique,\n Scale=MatchLowercase]{FreeSans}\n\\renewcommand{\\familydefault}{lmss}\n\\usepackage[LGRgreek,defaultmathsizes,noasterisk]{mathastext}\n\\renewcommand{\\familydefault}{\\sfdefault}\n\\Mathastext\n\\let\\varphi\\phi % no `var' phi in LGR encoding\n\\renewcommand{\\familydefault}{\\rmdefault}\n", placeholder_text='YourTextHere', post_doc_commands='')¶
GNU FreeSerif and FreeSans
- helvetica_fourier_it = TexTemplate(_body='', tex_compiler='latex', description='Helvetica with Fourier (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[scaled]{helvet}\n\\usepackage{fourier}\n\\renewcommand{\\rmdefault}{phv}\n\\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Helvetica with Fourier (Italic)
- latin_modern_tw = TexTemplate(_body='', tex_compiler='latex', description='Latin Modern Typewriter Proportional', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[variablett]{lmodern}\n\\renewcommand{\\rmdefault}{\\ttdefault}\n\\usepackage[LGRgreek]{mathastext}\n\\MTgreekfont{lmtt} % no lgr lmvtt, so use lgr lmtt\n\\Mathastext\n\\let\\varepsilon\\epsilon % only \\varsigma in LGR\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Latin Modern Typewriter Proportional
- latin_modern_tw_it = TexTemplate(_body='', tex_compiler='latex', description='Latin Modern Typewriter Proportional (CM Greek) (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[variablett,nomath]{lmodern}\n\\renewcommand{\\familydefault}{\\ttdefault}\n\\usepackage[frenchmath]{mathastext}\n\\linespread{1.08}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Latin Modern Typewriter Proportional (CM Greek) (Italic)
- libertine = TexTemplate(_body='', tex_compiler='latex', description='Libertine', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{libertine}\n\\usepackage[greek=n]{libgreek}\n\\usepackage[noasterisk,defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Libertine
- libris_adf_fourier = TexTemplate(_body='', tex_compiler='latex', description='Libris ADF with Fourier', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage[upright]{fourier}\n\\usepackage{libris}\n\\renewcommand{\\familydefault}{\\sfdefault}\n\\usepackage[noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Libris ADF with Fourier
- minion_pro_myriad_pro = TexTemplate(_body='', tex_compiler='xelatex', description='Minion Pro and Myriad Pro (and TX fonts symbols)', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{txfonts}\n\\usepackage[upright]{txgreeks}\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Minion Pro}\n\\setsansfont[Mapping=tex-text,Scale=MatchUppercase]{Myriad Pro}\n\\renewcommand\\familydefault\\sfdefault\n\\usepackage[defaultmathsizes]{mathastext}\n\\renewcommand\\familydefault\\rmdefault\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Minion Pro and Myriad Pro (and TX fonts symbols)
- minion_pro_tx = TexTemplate(_body='', tex_compiler='xelatex', description='Minion Pro (and TX fonts symbols)', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{txfonts}\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Minion Pro}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Minion Pro (and TX fonts symbols)
- new_century_schoolbook = TexTemplate(_body='', tex_compiler='latex', description='New Century Schoolbook (Symbol Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{newcent}\n\\usepackage[symbolgreek]{mathastext}\n\\linespread{1.1}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
New Century Schoolbook (Symbol Greek)
- new_century_schoolbook_px = TexTemplate(_body='', tex_compiler='latex', description='New Century Schoolbook (Symbol Greek, PX math symbols)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{pxfonts}\n\\usepackage{newcent}\n\\usepackage[symbolgreek,defaultmathsizes]{mathastext}\n\\linespread{1.06}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
New Century Schoolbook (Symbol Greek, PX math symbols)
- noteworthy_light = TexTemplate(_body='', tex_compiler='latex', description='Noteworthy Light', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Noteworthy Light}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Noteworthy Light
- palatino = TexTemplate(_body='', tex_compiler='latex', description='Palatino (Symbol Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{palatino}\n\\usepackage[symbolmax,defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Palatino (Symbol Greek)
- papyrus = TexTemplate(_body='', tex_compiler='xelatex', description='Papyrus', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Papyrus}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Papyrus
- romande_adf_fourier_it = TexTemplate(_body='', tex_compiler='latex', description='Romande ADF with Fourier (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{fourier}\n\\usepackage{romande}\n\\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}\n\\renewcommand{\\itshape}{\\swashstyle}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Romande ADF with Fourier (Italic)
- slitex = TexTemplate(_body='', tex_compiler='latex', description='SliTeX (Euler Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{tpslifonts}\n\\usepackage[eulergreek,defaultmathsizes]{mathastext}\n\\MTEulerScale{1.06}\n\\linespread{1.2}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
SliTeX (Euler Greek)
- times_fourier_it = TexTemplate(_body='', tex_compiler='latex', description='Times with Fourier (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{fourier}\n\\renewcommand{\\rmdefault}{ptm}\n\\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Times with Fourier (Italic)
- urw_avant_garde = TexTemplate(_body='', tex_compiler='latex', description='URW Avant Garde (Symbol Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{avant}\n\\renewcommand{\\familydefault}{\\sfdefault}\n\\usepackage[symbolgreek,defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
URW Avant Garde (Symbol Greek)
- urw_zapf_chancery = TexTemplate(_body='', tex_compiler='latex', description='URW Zapf Chancery (CM Greek)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\DeclareFontFamily{T1}{pzc}{}\n\\DeclareFontShape{T1}{pzc}{mb}{it}{<->s*[1.2] pzcmi8t}{}\n\\DeclareFontShape{T1}{pzc}{m}{it}{<->ssub * pzc/mb/it}{}\n\\DeclareFontShape{T1}{pzc}{mb}{sl}{<->ssub * pzc/mb/it}{}\n\\DeclareFontShape{T1}{pzc}{m}{sl}{<->ssub * pzc/mb/sl}{}\n\\DeclareFontShape{T1}{pzc}{m}{n}{<->ssub * pzc/mb/it}{}\n\\usepackage{chancery}\n\\usepackage{mathastext}\n\\linespread{1.05}', placeholder_text='YourTextHere', post_doc_commands='\n\\boldmath\n')¶
URW Zapf Chancery (CM Greek)
- venturis_adf_fourier_it = TexTemplate(_body='', tex_compiler='latex', description='Venturis ADF with Fourier (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{fourier}\n\\usepackage[lf]{venturis}\n\\usepackage[italic,defaultmathsizes,noasterisk]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Venturis ADF with Fourier (Italic)
- verdana_it = TexTemplate(_body='', tex_compiler='xelatex', description='Verdana (Italic)', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[no-math]{fontspec}\n\\setmainfont[Mapping=tex-text]{Verdana}\n\\usepackage[defaultmathsizes,italic]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Verdana (Italic)
- vollkorn = TexTemplate(_body='', tex_compiler='latex', description='Vollkorn (TX fonts for Greek and math symbols)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage[T1]{fontenc}\n\\usepackage{txfonts}\n\\usepackage[upright]{txgreeks}\n\\usepackage{vollkorn}\n\\usepackage[defaultmathsizes]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Vollkorn (TX fonts for Greek and math symbols)
- vollkorn_fourier_it = TexTemplate(_body='', tex_compiler='latex', description='Vollkorn with Fourier (Italic)', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\usepackage{fourier}\n\\usepackage{vollkorn}\n\\usepackage[italic,nohbar]{mathastext}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Vollkorn with Fourier (Italic)
- zapf_chancery = TexTemplate(_body='', tex_compiler='latex', description='Zapf Chancery', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\n\n\\DeclareFontFamily{T1}{pzc}{}\n\\DeclareFontShape{T1}{pzc}{mb}{it}{<->s*[1.2] pzcmi8t}{}\n\\DeclareFontShape{T1}{pzc}{m}{it}{<->ssub * pzc/mb/it}{}\n\\usepackage{chancery} % = \\renewcommand{\\rmdefault}{pzc}\n\\renewcommand\\shapedefault\\itdefault\n\\renewcommand\\bfdefault\\mddefault\n\\usepackage[defaultmathsizes]{mathastext}\n\\linespread{1.05}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
Zapf Chancery
TexTemplate¶
LaTeX 导言区模板:自定义宏包、字体、命令,Tex/MathTex 渲染的编译配置。
参数¶
|
'latex',str | list[str] |
|---|---|
|
'',str |
|
'.dvi',str |
|
'\documentclass[preview]{s…,str |
|
'\usepackage[english]{babe…,str |
|
'YourTextHere',str |
|
'',str |
快速上手¶
tpl = TexTemplate()
tpl.add_to_preamble("\usepackage{amsmath}")
API 文档¶
- class manim.TexTemplate(tex_compiler: str | list[str] = 'latex', description: str = '', output_format: str = '.dvi', documentclass: str = '\\documentclass[preview]{standalone}', preamble: str = '\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}', placeholder_text: str = 'YourTextHere', post_doc_commands: str = '')¶
基类:
object- add_to_document(txt: str) Self¶
Adds text to the TeX template just after begin{document}, e.g.
\boldmath.Parameters¶
- txt
String containing the text to be added.
- add_to_preamble(txt: str, prepend: bool = False) Self¶
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
String containing the text to be added, e.g.
\usepackage{hyperref}.- prepend
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}.
- property body: str¶
The entire TeX template.
- copy() Self¶
Create a deep copy of the TeX template instance.
- 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: StrPath = 'tex_template.tex', **kwargs: Any) Self¶
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.
- get_texcode_for_expression(expression: str) str¶
Inserts expression verbatim into TeX template.
Parameters¶
- expression
The string containing the expression to be typeset, e.g.
$\sqrt{2}$
Returns¶
strLaTeX code based on current template, containing the given
expressionand ready for typesetting
- get_texcode_for_expression_in_env(expression: str, environment: str) str¶
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 the environment in which the expression should be typeset, e.g.
align*.
Returns¶
strLaTeX code based on template, containing the given expression inside its environment, ready for typesetting
- 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 | list[str] = 'latex'¶
The TeX compiler(s) to be used. Can be a single compiler (e.g.
"latex","pdflatex","lualatex") or a list of compilers to compile in order (e.g.["lualatex", "pdflatex"]).
TexTemplateLibrary¶
常用 TexTemplate 的预置库:ctex、standalone 等开箱模板。
API 文档¶
- class manim.TexTemplateLibrary¶
基类:
object- ctex = TexTemplate(_body='', tex_compiler='xelatex', description='', output_format='.xdv', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{lmodern}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{dsfont}\n\\usepackage{setspace}\n\\usepackage{tipa}\n\\usepackage{relsize}\n\\usepackage{textcomp}\n\\usepackage{mathrsfs}\n\\usepackage{calligra}\n\\usepackage{wasysym}\n\\usepackage{ragged2e}\n\\usepackage{physics}\n\\usepackage{xcolor}\n\\usepackage{microtype}\n\\usepackage[UTF8]{ctex}\n\\linespread{1}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
An instance of the TeX template used by 3b1b when using the use_ctex flag
- default = TexTemplate(_body='', tex_compiler='latex', description='', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{lmodern}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{dsfont}\n\\usepackage{setspace}\n\\usepackage{tipa}\n\\usepackage{relsize}\n\\usepackage{textcomp}\n\\usepackage{mathrsfs}\n\\usepackage{calligra}\n\\usepackage{wasysym}\n\\usepackage{ragged2e}\n\\usepackage{physics}\n\\usepackage{xcolor}\n\\usepackage{microtype}\n\\DisableLigatures{encoding = *, family = * }\n\\linespread{1}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
An instance of the default TeX template in manim
- simple = TexTemplate(_body='', tex_compiler='latex', description='', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
An instance of a simple TeX template with only basic AMS packages loaded
- threeb1b = TexTemplate(_body='', tex_compiler='latex', description='', output_format='.dvi', documentclass='\\documentclass[preview]{standalone}', preamble='\n\\usepackage[english]{babel}\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{lmodern}\n\\usepackage{amsmath}\n\\usepackage{amssymb}\n\\usepackage{dsfont}\n\\usepackage{setspace}\n\\usepackage{tipa}\n\\usepackage{relsize}\n\\usepackage{textcomp}\n\\usepackage{mathrsfs}\n\\usepackage{calligra}\n\\usepackage{wasysym}\n\\usepackage{ragged2e}\n\\usepackage{physics}\n\\usepackage{xcolor}\n\\usepackage{microtype}\n\\DisableLigatures{encoding = *, family = * }\n\\linespread{1}\n', placeholder_text='YourTextHere', post_doc_commands='')¶
An instance of the default TeX template used by 3b1b