我试着编译以下代码:
class I3(Scene):
def construct(self):
z = Tex("e^{itheta}=cos(theta)+isin(theta)")
self.add(z)
self.wait(5)
但是我得到了这个错误:
ValueError: latex error converting to dvi. See log output above or the log file: media/Tex/d946638dc8ff7097.log
提到的.log文件是:
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (MiKTeX 22.3) (preloaded format=latex 2022.7.16) 17 JUL 2022 18:20
entering extended mode
restricted write18 enabled.
%&-line parsing enabled.
**./media/Tex/d946638dc8ff7097.tex
(media/Tex/d946638dc8ff7097.tex
LaTeX2e <2022-06-01> patch level 3
L3 programming layer <2022-06-16> (C:Program FilesMiKTeXtex/latex/standalone
standalone.cls
Document Class: standalone 2018/03/26 v1.3a Class to compile TeX sub-files stan
dalone
(C:Program FilesMiKTeXtex/latex/toolsshellesc.sty
Package: shellesc 2019/11/08 v1.0c unified shell escape interface for LaTeX
Package shellesc Info: Restricted shell escape enabled on input line 77.
) (C:Program FilesMiKTeXtex/generic/iftexifluatex.sty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
(C:Program FilesMiKTeXtex/generic/iftexiftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
)) (C:Program FilesMiKTeXtex/latex/xkeyvalxkeyval.sty
Package: xkeyval 2022/06/16 v2.9 package option processing (HA)
(C:Program FilesMiKTeXtex/generic/xkeyvalxkeyval.tex (C:Program FilesMiKT
eXtex/generic/xkeyvalxkvutils.tex
XKV@toks=toks16
XKV@tempa@toks=toks17
(C:Program FilesMiKTeXtex/generic/xkeyvalkeyval.tex))
XKV@depth=count185
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
sa@internal=count186
c@sapage=count187
(C:Program FilesMiKTeXtex/latex/standalonestandalone.cfg
File: standalone.cfg 2018/03/26 v1.3a Default configuration file for 'standalon
e' class
) (C:Program FilesMiKTeXtex/latex/basearticle.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(C:Program FilesMiKTeXtex/latex/basesize10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
c@part=count188
c@section=count189
c@subsection=count190
c@subsubsection=count191
c@paragraph=count192
c@subparagraph=count193
c@figure=count194
c@table=count195
abovecaptionskip=skip47
belowcaptionskip=skip48
bibindent=dimen138
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/previewpreview.sty
Package: preview 2017/04/24 13.1 (AUCTeX/preview-latex)
(C:Program FilesMiKTeXtex/latex/luatex85luatex85.sty
Package: luatex85 2016/06/15 v1.4 pdftex aliases for luatex
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/previewprtightpage.def
PreviewBorder=dimen139
)
pr@snippet=count196
pr@box=box51
pr@output=toks18
)) (C:Program FilesMiKTeXtex/generic/babelbabel.sty
Package: babel 2022/06/06 3.76 The Babel package
babel@savecnt=count197
U@D=dimen140
l@unhyphenated=language79
(C:Program FilesMiKTeXtex/generic/babeltxtbabel.def)
bbl@readstream=read2
bbl@dirlevel=count198
*************************************
* Local config file bblopts.cfg used
*
(C:Program FilesMiKTeXtex/latex/arabibblopts.cfg
File: bblopts.cfg 2005/09/08 v0.1 add Arabic and Farsi to "declared" options of
babel
) (C:Program FilesMiKTeXtex/latex/babel-englishenglish.ldf
Language: english 2017/06/06 v3.3r English support from the babel system
Package babel Info: Hyphen rules for 'canadian' set to l@english
(babel) (language0). Reported on input line 102.
Package babel Info: Hyphen rules for 'australian' set to l@ukenglish
(babel) (language73). Reported on input line 105.
Package babel Info: Hyphen rules for 'newzealand' set to l@ukenglish
(babel) (language73). Reported on input line 108.
)) (C:Program FilesMiKTeXtex/generic/babel/locale/enbabel-english.tex
Package babel Info: Importing font and identification data for english
(babel) from babel-en.ini. Reported on input line 11.
) (C:Program FilesMiKTeXtex/latex/baseinputenc.sty
Package: inputenc 2021/02/14 v1.3d Input encoding file
inpenc@prehook=toks19
inpenc@posthook=toks20
) (C:Program FilesMiKTeXtex/latex/basefontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
) (C:Program FilesMiKTeXtex/latex/lmlmodern.sty
Package: lmodern 2015/05/01 v1.6.1 Latin Modern Fonts
LaTeX Font Info: Overwriting symbol font `operators' in version `normal'
(Font) OT1/cmr/m/n --> OT1/lmr/m/n on input line 22.
LaTeX Font Info: Overwriting symbol font `letters' in version `normal'
(Font) OML/cmm/m/it --> OML/lmm/m/it on input line 23.
LaTeX Font Info: Overwriting symbol font `symbols' in version `normal'
(Font) OMS/cmsy/m/n --> OMS/lmsy/m/n on input line 24.
LaTeX Font Info: Overwriting symbol font `largesymbols' in version `normal'
(Font) OMX/cmex/m/n --> OMX/lmex/m/n on input line 25.
LaTeX Font Info: Overwriting symbol font `operators' in version `bold'
(Font) OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 26.
LaTeX Font Info: Overwriting symbol font `letters' in version `bold'
(Font) OML/cmm/b/it --> OML/lmm/b/it on input line 27.
LaTeX Font Info: Overwriting symbol font `symbols' in version `bold'
(Font) OMS/cmsy/b/n --> OMS/lmsy/b/n on input line 28.
LaTeX Font Info: Overwriting symbol font `largesymbols' in version `bold'
(Font) OMX/cmex/m/n --> OMX/lmex/m/n on input line 29.
LaTeX Font Info: Overwriting math alphabet `mathbf' in version `normal'
(Font) OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 31.
LaTeX Font Info: Overwriting math alphabet `mathsf' in version `normal'
(Font) OT1/cmss/m/n --> OT1/lmss/m/n on input line 32.
LaTeX Font Info: Overwriting math alphabet `mathit' in version `normal'
(Font) OT1/cmr/m/it --> OT1/lmr/m/it on input line 33.
LaTeX Font Info: Overwriting math alphabet `mathtt' in version `normal'
(Font) OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 34.
LaTeX Font Info: Overwriting math alphabet `mathbf' in version `bold'
(Font) OT1/cmr/bx/n --> OT1/lmr/bx/n on input line 35.
LaTeX Font Info: Overwriting math alphabet `mathsf' in version `bold'
(Font) OT1/cmss/bx/n --> OT1/lmss/bx/n on input line 36.
LaTeX Font Info: Overwriting math alphabet `mathit' in version `bold'
(Font) OT1/cmr/bx/it --> OT1/lmr/bx/it on input line 37.
LaTeX Font Info: Overwriting math alphabet `mathtt' in version `bold'
(Font) OT1/cmtt/m/n --> OT1/lmtt/m/n on input line 38.
) (C:Program FilesMiKTeXtex/latex/amsmathamsmath.sty
Package: amsmath 2022/04/08 v2.17n AMS math features
@mathmargin=skip49
For additional information on amsmath, use the `?' option.
(C:Program FilesMiKTeXtex/latex/amsmathamstext.sty
Package: amstext 2021/08/26 v2.01 AMS text
(C:Program FilesMiKTeXtex/latex/amsmathamsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
@emptytoks=toks21
ex@=dimen141
)) (C:Program FilesMiKTeXtex/latex/amsmathamsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
pmbraise@=dimen142
) (C:Program FilesMiKTeXtex/latex/amsmathamsopn.sty
Package: amsopn 2022/04/08 v2.04 operator names
)
inf@bad=count199
LaTeX Info: Redefining frac on input line 234.
uproot@=count266
leftroot@=count267
LaTeX Info: Redefining overline on input line 399.
LaTeX Info: Redefining colon on input line 410.
classnum@=count268
DOTSCASE@=count269
LaTeX Info: Redefining ldots on input line 496.
LaTeX Info: Redefining dots on input line 499.
LaTeX Info: Redefining cdots on input line 620.
Mathstrutbox@=box52
strutbox@=box53
LaTeX Info: Redefining big on input line 722.
LaTeX Info: Redefining Big on input line 723.
LaTeX Info: Redefining bigg on input line 724.
LaTeX Info: Redefining Bigg on input line 725.
big@size=dimen143
LaTeX Font Info: Redeclaring font encoding OML on input line 743.
LaTeX Font Info: Redeclaring font encoding OMS on input line 744.
macc@depth=count270
LaTeX Info: Redefining bmod on input line 905.
LaTeX Info: Redefining pmod on input line 910.
LaTeX Info: Redefining smash on input line 940.
LaTeX Info: Redefining relbar on input line 970.
LaTeX Info: Redefining Relbar on input line 971.
c@MaxMatrixCols=count271
dotsspace@=muskip16
c@parentequation=count272
dspbrk@lvl=count273
tag@help=toks22
row@=count274
column@=count275
maxfields@=count276
andhelp@=toks23
eqnshift@=dimen144
alignsep@=dimen145
tagshift@=dimen146
tagwidth@=dimen147
totwidth@=dimen148
lineht@=dimen149
@envbody=toks24
multlinegap=skip50
multlinetaggap=skip51
mathdisplay@stack=toks25
LaTeX Info: Redefining [ on input line 2953.
LaTeX Info: Redefining ] on input line 2954.
) (C:Program FilesMiKTeXtex/latex/amsfontsamssymb.sty
Package: amssymb 2013/01/14 v3.01 AMS font symbols
(C:Program FilesMiKTeXtex/latex/amsfontsamsfonts.sty
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
symAMSa=mathgroup4
symAMSb=mathgroup5
LaTeX Font Info: Redeclaring math symbol hbar on input line 98.
LaTeX Font Info: Overwriting math alphabet `mathfrak' in version `bold'
(Font) U/euf/m/n --> U/euf/b/n on input line 106.
)) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/doublestrokedsfont.sty
Package: dsfont 1995/08/01 v0.1 Double stroke roman fonts
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/setspacesetspace.sty
Package: setspace 2011/12/19 v6.7a set line spacing
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/tipatipa.sty
Package: tipa 2002/08/08 TIPA version 1.1
(C:Program FilesMiKTeXtex/latex/basefontenc.sty
Package: fontenc 2021/04/29 v2.0v Standard LaTeX package
(C:UsersselaeAppDataRoamingMiKTeXtex/latex/tipat3enc.def
File: t3enc.def 2001/12/31 T3 encoding
Now handling font encoding T3 ...
... no UTF-8 mapping file for font encoding T3
LaTeX Font Info: Trying to load font information for T1+lmss on input line 3
57.
(C:Program FilesMiKTeXtex/latex/lmt1lmss.fd
File: t1lmss.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
))
LaTeX Font Info: Trying to load font information for T1+lmr on input line 11
2.
(C:Program FilesMiKTeXtex/latex/lmt1lmr.fd
File: t1lmr.fd 2015/05/01 v1.6.1 Font defs for Latin Modern
))) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/relsizerelsize.sty
Package: relsize 2013/03/29 ver 4.1
) (C:Program FilesMiKTeXtex/latex/basetextcomp.sty
Package: textcomp 2020/02/02 v2.0n Standard LaTeX package
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/jknappenmathrsfs.sty
Package: mathrsfs 1996/01/01 Math RSFS package v1.0 (jk)
symrsfs=mathgroup6
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/fundus-calligracalligra.sty
Package: calligra 2012/04/10 v1.9 LaTeX package calligra
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/wasysymwasysym.sty
Package: wasysym 2020/01/19 v2.4 Wasy-2 symbol support package
symwasy=mathgroup7
LaTeX Font Info: Overwriting symbol font `wasy' in version `bold'
(Font) U/wasy/m/n --> U/wasy/b/n on input line 93.
) (C:Program FilesMiKTeXtex/latex/ragged2eragged2e.sty
Package: ragged2e 2021/12/15 v3.1 ragged2e Package
CenteringLeftskip=skip52
RaggedLeftLeftskip=skip53
RaggedRightLeftskip=skip54
CenteringRightskip=skip55
RaggedLeftRightskip=skip56
RaggedRightRightskip=skip57
CenteringParfillskip=skip58
RaggedLeftParfillskip=skip59
RaggedRightParfillskip=skip60
JustifyingParfillskip=skip61
CenteringParindent=skip62
RaggedLeftParindent=skip63
RaggedRightParindent=skip64
JustifyingParindent=skip65
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/physicsphysics.sty
Package: physics
(C:Program FilesMiKTeXtex/latex/l3packages/xparsexparse.sty (C:Program Fil
esMiKTeXtex/latex/l3kernelexpl3.sty
Package: expl3 2022-06-16 L3 programming layer (loader)
(C:Program FilesMiKTeXtex/latex/l3backendl3backend-dvips.def
File: l3backend-dvips.def 2022-04-20 L3 backend support: dvips
l__pdf_internal_box=box54
g__pdf_backend_object_int=count277
l__pdf_backend_content_box=box55
l__pdf_backend_model_box=box56
g__pdf_backend_annotation_int=count278
g__pdf_backend_link_int=count279
g__pdf_backend_link_sf_int=count280
))
Package: xparse 2022-06-22 L3 Experimental document command parser
)) (C:Program FilesMiKTeXtex/latex/xcolorxcolor.sty
Package: xcolor 2022/06/12 v2.14 LaTeX color extensions (UK)
(C:Program FilesMiKTeXtex/latex/graphics-cfgcolor.cfg
File: color.cfg 2016/01/02 v1.6 sample color configuration
)
Package xcolor Info: Driver file: dvips.def on input line 227.
(C:Program FilesMiKTeXtex/latex/graphics-defdvips.def
File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex-dev/graphicsmathcolor.ltx)
Package xcolor Info: Model `cmy' substituted by `cmy0' on input line 1353.
Package xcolor Info: Model `RGB' extended on input line 1369.
Package xcolor Info: Model `HTML' substituted by `rgb' on input line 1371.
Package xcolor Info: Model `Hsb' substituted by `hsb' on input line 1372.
Package xcolor Info: Model `tHsb' substituted by `hsb' on input line 1373.
Package xcolor Info: Model `HSB' substituted by `hsb' on input line 1374.
Package xcolor Info: Model `Gray' substituted by `gray' on input line 1375.
Package xcolor Info: Model `wave' substituted by `hsb' on input line 1376.
) (C:UsersselaeAppDataRoamingMiKTeXtex/latex/microtypemicrotype.sty
Package: microtype 2022/06/23 v3.0f Micro-typographical refinements (RS)
(C:Program FilesMiKTeXtex/latex/etoolboxetoolbox.sty
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
etb@tempcnta=count281
)
MT@toks=toks26
MT@tempbox=box57
MT@count=count282
LaTeX Info: Redefining noprotrusionifhmode on input line 1045.
LaTeX Info: Redefining leftprotrusion on input line 1046.
LaTeX Info: Redefining rightprotrusion on input line 1056.
LaTeX Info: Redefining textls on input line 1234.
MT@outer@kern=dimen150
LaTeX Info: Redefining textmicrotypecontext on input line 1858.
MT@listname@count=count283
(C:UsersselaeAppDataRoamingMiKTeXtex/latex/microtypemicrotype-pdftex.def
File: microtype-pdftex.def 2022/06/23 v3.0f Definitions specific to pdftex (RS)
LaTeX Info: Redefining lsstyle on input line 900.
LaTeX Info: Redefining lslig on input line 900.
MT@outer@space=skip66
)
Package microtype Info: Loading configuration file microtype.cfg.
(C:UsersselaeAppDataRoamingMiKTeXtex/latex/microtypemicrotype.cfg
File: microtype.cfg 2022/06/23 v3.0f microtype main configuration file (RS)
))
No file d946638dc8ff7097.aux.
openout1 = `d946638dc8ff7097.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 24.
LaTeX Font Info: ... okay on input line 24.
LaTeX Font Info: Checking defaults for T3/cmr/m/n on input line 24.
LaTeX Font Info: Trying to load font information for T3+cmr on input line 24
.
(C:UsersselaeAppDataRoamingMiKTeXtex/latex/tipat3cmr.fd
File: t3cmr.fd 2001/12/31 TIPA font definitions
)
LaTeX Font Info: ... okay on input line 24.
Preview: Fontsize 10pt
LaTeX Info: Redefining microtypecontext on input line 24.
Package microtype Info: Applying patch `item' on input line 24.
Package microtype Info: Applying patch `toc' on input line 24.
Package microtype Info: Applying patch `eqnum' on input line 24.
Package microtype Info: Applying patch `footnote' on input line 24.
Package microtype Info: Generating DVI output.
Package microtype Info: Character protrusion enabled (level 2).
Package microtype Info: Using default protrusion set `alltext'.
Package microtype Info: No font expansion.
Package microtype Info: No adjustment of tracking.
Package microtype Info: No adjustment of interword spacing.
Package microtype Info: No adjustment of character kerning.
(C:UsersselaeAppDataRoamingMiKTeXtex/latex/microtypemt-cmr.cfg
File: mt-cmr.cfg 2013/05/19 v2.2 microtype config. file: Computer Modern Roman
(RS)
)
! Missing $ inserted.
<inserted text>
$
l.27 e^
{i heta}=cos( heta)+isin( heta)
Here is how much of TeX's memory you used:
8382 strings out of 478352
131308 string characters out of 2846893
474783 words of memory out of 3000000
26693 multiletter control sequences out of 15000+600000
478062 words of font info for 34 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
72i,2n,77p,1025b,170s stack positions out of 10000i,1000n,20000p,200000b,80000s
No pages of output.
下面的代码可以正常工作:
class I3(Scene):
def construct(self):
z = Tex("LaTeX")
self.add(z)
self.wait(5)
这让我相信有一些丢失的包,经过一些挖掘,我看到一些人建议在manimlib文件夹中运行latex tex_template.tex
,但我在计算机上找不到这个文件夹。是什么导致了这个问题,我该如何解决它?
您没有提到您使用的是manimgl还是社区维护的Manim版本,但从错误判断,我猜您正在运行社区维护的版本(from manim import *
)。
在这种情况下,Tex
在正常模式下呈现TeX,MathTex
在align*
环境中插入字符串(因此,在数学模式下)。这就是日志文件末尾的错误所抱怨的内容:
! Missing $ inserted.
<inserted text>
$
l.27 e^
{i heta}=cos( heta)+isin( heta)
这实际上也揭示了代码的第二个问题,考虑到t
已经被空格取代:是Python字符串中的一个特殊字符;要实际编写
,您需要通过编写
\
来转义它——或者,或者,通过在字符串之前放置r
来使用原始字符串。
TL;DR,这是你想要的:
class I3(Scene):
def construct(self):
z = MathTex(r"e^{itheta}=cos(theta)+isin(theta)")
self.add(z)
self.wait(5)