如何解决带有 Manim 的长文本
在使用 Manim 库的社区版呈现长文本时,我注意到信息呈现在可见窗口之外,效果并不令人满意。我怀疑问题的根源是 Latex 未能确保文本保持在 pdf 边界内。有没有自动换行文本的方法?我不想手动指定换行符,因为文本将不再对齐。
这是一个最小的例子:
from manim import *
class Edge_Wise(Scene):
def construct(self):
text=Tex("\\text{First we conceptualize an undirected graph ${G}$ as a union of a finite number of line segments residing in ${\\mathbb{{{C}}}}$ . By taking our earlier parametrization,we can create an almost trivial extension to ${\\mathbb{{{R}}}}^{{{3}}}$ . In the following notation,we write a bicomplex number of a 2-tuple of complex numbers,the latter of which is multiplied by the constant ${j}$ . ${z}_{{0}}\\in{\\mathbb{{{C}}}}_{{>={0}}}$ is an arbitrary point in the upper half plane from which the contour integral begins. The function ${\\tan{{\\left(\\frac{{{\\theta}-{\\pi}}}{{z}}\\right)}}}:{\\left[{0},{2}{\\pi}\\right)}\\to{\\left[-\\infty,\\infty\\right)}$ ensures that the vertices at $\\infty$ for the Schwarz-Christoffel transform correspond to points along the branch cut at ${\\mathbb{{{R}}}}_{{+}}$ .}")
text.scale(0.6)
self.play(FadeIn(text))
self.wait(1)
self.play(FadeOut(text))
解决方法
您使用的 \text
环境未包装。它旨在将文本格式化为数学模式中的文本,当您在 $...$
之外时不需要它。以下示例为您提供两端对齐的文本:
class SquareToCircle(Scene):
def construct(self):
text=Tex("\\justifying {First we conceptualize an undirected graph ${G}$ as a union of a finite number of line segments residing in ${\\mathbb{{{C}}}}$ . By taking our earlier parametrization,we can create an almost trivial extension to ${\\mathbb{{{R}}}}^{}$ . In the following notation,we write a bicomplex number of a 2-tuple of complex numbers,the latter of which is multiplied by the constant ${j}$ . ${z}_\\in{\\mathbb{{{C}}}}_{{>={0}}}$ is an arbitrary point in the upper half plane from which the contour integral begins. The function ${\\tan{{\\left(\\frac{{{\\theta}-{\\pi}}}{{z}}\\right)}}}:{\\left[{0},{2}{\\pi}\\right)}\\to{\\left[-\\infty,\\infty\\right)}$ ensures that the vertices at $\\infty$ for the Schwarz-Christoffel transform correspond to points along the branch cut at ${\\mathbb{{{R}}}}_{{+}}$ .}")
text.scale(0.6)
self.play(FadeIn(text))
self.wait(1)
self.play(FadeOut(text))
结果: STACKOVERFLOW
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。