ManimCommunity / manim

A community-maintained Python framework for creating mathematical animations.
https://www.manim.community
MIT License
22.49k stars 1.63k forks source link

circuiTikz won't compile in v0.7 #1618

Closed Ribisl closed 3 years ago

Ribisl commented 3 years ago

I updated to version 0.7 today and noticed, that my circuiTikz latex won't compile anymore

Error code: [06/02/21 19:29:14] ERROR LaTeX compilation error: {log[error_pos][2:])} tex_file_writing.py:198 ERROR Context for error: tex_file_writing.py:223 \begin{circuitikz}[european,straight voltages] \draw (0,0) to [R=$R_3$] (0,2) to [C,C=C, i_<=$\underline{I}_1$](-2,2); \draw (0,2) to[short,i_<=$\underline{I}_2$] (2,2); \draw (0,0) to [short] (2,0); \draw (0,0) to [short] (-2,0); \draw (2,2) to [open,v_=$\underline{U}_2$] (2,0); \draw (-2,2) to [open,v_=$\underline{U}_1$] (-2,0); \end{circuitikz} \end{align*} ^ this line

In v0.6 they worked fine, except that you had to change the opacity and the stroke to get acceptable results

kilacoda-old commented 3 years ago

Could you share the contents of the .log file? The one that's mentioned at the end of the traceback.

Ribisl commented 3 years ago

This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.3) (preloaded format=latex 2021.6.1) 2 JUN 2021 20:41 entering extended mode **./media/Tex/d4d6a6fd809d8da4.tex (media/Tex/d4d6a6fd809d8da4.tex LaTeX2e <2020-10-01> patch level 4 L3 programming layer <2021-05-27> (F:\ProgramData\Miktex2\tex/latex/standalone\ standalone.cls Document Class: standalone 2018/03/26 v1.3a Class to compile TeX sub-files stan dalone (F:\ProgramData\Miktex2\tex/latex/latex-tools\shellesc.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. ) (F:\ProgramData\Miktex2\tex/generic/iftex\ifluatex.sty Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead. (F:\ProgramData\Miktex2\tex/generic/iftex\iftex.sty Package: iftex 2020/03/06 v1.0d TeX engine tests )) (F:\ProgramData\Miktex2\tex/latex/xkeyval\xkeyval.sty Package: xkeyval 2020/11/20 v2.8 package option processing (HA) (F:\ProgramData\Miktex2\tex/generic/xkeyval\xkeyval.tex (F:\ProgramData\Miktex2 \tex/generic/xkeyval\xkvutils.tex \XKV@toks=\toks15 \XKV@tempa@toks=\toks16 (F:\ProgramData\Miktex2\tex/generic/xkeyval\keyval.tex)) \XKV@depth=\count181 File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA) )) \sa@internal=\count182 \c@sapage=\count183 (F:\ProgramData\Miktex2\tex/latex/standalone\standalone.cfg File: standalone.cfg 2018/03/26 v1.3a Default configuration file for 'standalon e' class ) (F:\ProgramData\Miktex2\tex/latex/base\article.cls Document Class: article 2020/04/10 v1.4m Standard LaTeX document class (F:\ProgramData\Miktex2\tex/latex/base\size10.clo File: size10.clo 2020/04/10 v1.4m Standard LaTeX file (size option) ) \c@part=\count184 \c@section=\count185 \c@subsection=\count186 \c@subsubsection=\count187 \c@paragraph=\count188 \c@subparagraph=\count189 \c@figure=\count190 \c@table=\count191 \abovecaptionskip=\skip47 \belowcaptionskip=\skip48 \bibindent=\dimen138 ) (F:\ProgramData\Miktex2\tex/latex/preview\preview.sty Package: preview 2017/04/24 12.3 (AUCTeX/preview-latex) (F:\ProgramData\Miktex2\tex/generic/luatex85\luatex85.sty Package: luatex85 2016/06/15 v1.4 pdftex aliases for luatex ) (F:\ProgramData\Miktex2\tex/latex/preview\prtightpage.def \PreviewBorder=\dimen139 ) \pr@snippet=\count192 \pr@box=\box47 \pr@output=\toks17 )) (F:\ProgramData\Miktex2\tex/generic/babel\babel.sty Package: babel 2021/05/16 3.59 The Babel package (F:\ProgramData\Miktex2\tex/generic/babel\babel.def File: babel.def 2021/05/16 3.59 Babel common definitions \babel@savecnt=\count193 \U@D=\dimen140 \l@unhyphenated=\language79 (F:\ProgramData\Miktex2\tex/generic/babel\txtbabel.def) \bbl@readstream=\read2 ) \bbl@dirlevel=\count194


LaTeX Info: Redefining \lsstyle on input line 915. LaTeX Info: Redefining \lslig on input line 915. \MT@outer@space=\skip66 ) Package microtype Info: Loading configuration file microtype.cfg. (F:\ProgramData\Miktex2\tex/latex/microtype\microtype.cfg File: microtype.cfg 2021/03/14 v2.8c microtype main configuration file (RS) )) No file d4d6a6fd809d8da4.aux. \openout1 = `d4d6a6fd809d8da4.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 . (F:\ProgramData\Miktex2\tex/latex/tipa\t3cmr.fd File: t3cmr.fd 2001/12/31 TIPA font definitions ) LaTeX Font Info: ... okay on input line 24. Preview: Fontsize 10pt ABD: EverySelectfont initializing macros LaTeX Info: Redefining \selectfont on input line 24. LaTeX Info: Redefining \microtypecontext 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. (F:\ProgramData\Miktex2\tex/latex/microtype\mt-cmr.cfg File: mt-cmr.cfg 2013/05/19 v2.2 microtype config. file: Computer Modern Roman (RS) ) LaTeX Font Info: Trying to load font information for OT1+lmr on input line 2 6. (F:\ProgramData\Miktex2\tex/latex/lm\ot1lmr.fd File: ot1lmr.fd 2009/10/30 v1.6 Font defs for Latin Modern ) LaTeX Font Info: Trying to load font information for OML+lmm on input line 2 6. (F:\ProgramData\Miktex2\tex/latex/lm\omllmm.fd File: omllmm.fd 2009/10/30 v1.6 Font defs for Latin Modern ) LaTeX Font Info: Trying to load font information for OMS+lmsy on input line 26. (F:\ProgramData\Miktex2\tex/latex/lm\omslmsy.fd File: omslmsy.fd 2009/10/30 v1.6 Font defs for Latin Modern ) LaTeX Font Info: Trying to load font information for OMX+lmex on input line 26. (F:\ProgramData\Miktex2\tex/latex/lm\omxlmex.fd File: omxlmex.fd 2009/10/30 v1.6 Font defs for Latin Modern ) LaTeX Font Info: External fontlmex10' loaded for size (Font) <10> on input line 26. LaTeX Font Info: External font lmex10' loaded for size (Font) <7> on input line 26. LaTeX Font Info: External fontlmex10' loaded for size (Font) <5> on input line 26. LaTeX Font Info: Trying to load font information for U+msa on input line 26.

(F:\ProgramData\Miktex2\tex/latex/amsfonts\umsa.fd File: umsa.fd 2013/01/14 v3.01 AMS symbols A ) (F:\ProgramData\Miktex2\tex/latex/microtype\mt-msa.cfg File: mt-msa.cfg 2006/02/04 v1.1 microtype config. file: AMS symbols (a) (RS) ) LaTeX Font Info: Trying to load font information for U+msb on input line 26.

(F:\ProgramData\Miktex2\tex/latex/amsfonts\umsb.fd File: umsb.fd 2013/01/14 v3.01 AMS symbols B ) (F:\ProgramData\Miktex2\tex/latex/microtype\mt-msb.cfg File: mt-msb.cfg 2005/06/01 v1.0 microtype config. file: AMS symbols (b) (RS) ) LaTeX Font Info: Trying to load font information for U+rsfs on input line 26 . (F:\ProgramData\Miktex2\tex/latex/jknappen\ursfs.fd File: ursfs.fd 1998/03/24 rsfs font definition file (jk) ) LaTeX Font Info: Trying to load font information for U+wasy on input line 26 . (F:\ProgramData\Miktex2\tex/latex/wasysym\uwasy.fd File: uwasy.fd 2020/01/19 v2.4 Wasy-2 symbol font definitions )

! LaTeX Error: Environment circuitikz undefined.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

l.38 \end{align*}

Here is how much of TeX's memory you used: 7497 strings out of 479082 108953 string characters out of 2863034 447456 words of memory out of 3000000 25034 multiletter control sequences out of 15000+600000 425641 words of font info for 55 fonts, out of 8000000 for 9000 1141 hyphenation exceptions out of 8191 70i,8n,81p,354b,233s stack positions out of 5000i,500n,10000p,200000b,80000s

No pages of output. d4d6a6fd809d8da4.log

behackl commented 3 years ago

! LaTeX Error: Environment circuitikz undefined.

This line says that you aren't loading the circuitikz package -- but we didn't change anything about the tex templates, and circuitikz was never automatically included in our default template as far as I can tell. Are you sure you are testing with the same code that you were using with v0.6.0?

Ribisl commented 3 years ago

yes I'm pretty sure, I added it in the v0.6 and there it worked!

behackl commented 3 years ago

Can you share the code that you were using?

Ribisl commented 3 years ago

aufgabe1.zip

Ribisl commented 3 years ago

I reinstalled everything again and it seems, that in the tex_template.py circuitikz was missing

behackl commented 3 years ago

You must have changed the file before as well, I otherwise don't have an explanation for why it would have worked before.

FYI: you can both configure a different tex template file for Manim to use instead of the one in the library folder, as well as piece together a suitable TexTemplate (look for the class in our documentation) to pass to MathTex.

Given that this seems to be resolved now, I'll close the issue (feel free to keep commenting if you see this otherwise!)

0xCoto commented 3 years ago

Hi @Ribisl - Have you managed to install Circuitikz on v0.9.0 as well? I'm facing problems after updating, but I tried the mathrsfs package example here and it worked fine. So it seems to be a package-specific issue, not quite sure...

(Looks like we're both working on similar RF engineering topics by the way haha!)


My code:

from manim import *

class AddPackageLatex(Scene):
    def construct(self):
        myTemplate = TexTemplate()
        myTemplate.add_to_preamble(r"\usepackage{circuitikz}")
        circuit="""\\begin{circuitikz}[american]
                    \\draw[ultra thin](-2.64,0) to [R] (0,0) to [cute inductor] (2.64,-0);
                    \\draw[ultra thin](0,0) to [capacitor,l^] (0,-1) to (0,-0.8) node[ground]{};;
                    \\end{circuitikz}"""
        tex = Tex(circuit, tex_template=myTemplate).scale(3)
        self.add(tex)

Error output:

Manim Community v0.9.0

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/Coto/Library/Python/3.9/lib/python/site-packages/manim/cli/render/commands.py:135 in      │
│ render                                                                                           │
│                                                                                                  │
│   132 │   │   for SceneClass in scene_classes_from_file(file):                                   │
│   133 │   │   │   try:                                                                           │
│   134 │   │   │   │   scene = SceneClass()                                                       │
│ ❱ 135 │   │   │   │   scene.render()                                                             │
│   136 │   │   │   except Exception:                                                              │
│   137 │   │   │   │   error_console.print_exception()                                            │
│   138 │   │   │   │   sys.exit(1)                                                                │
│                                                                                                  │
│ /Users/Coto/Library/Python/3.9/lib/python/site-packages/manim/scene/scene.py:215 in render       │
│                                                                                                  │
│    212 │   │   """                                                                               │
│    213 │   │   self.setup()                                                                      │
│    214 │   │   try:                                                                              │
│ ❱  215 │   │   │   self.construct()                                                              │
│    216 │   │   except EndSceneEarlyException:                                                    │
│    217 │   │   │   pass                                                                          │
│    218 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ /Users/Coto/Documents/edu/sometest.py:11 in construct                                            │
│                                                                                                  │
│    8 │   │   │   │   │   \\draw[ultra thin](-2.64,0) to [R] (0,0) to [cute inductor] (2.64,-0    │
│    9 │   │   │   │   │   \\draw[ultra thin](0,0) to [capacitor,l^] (0,-1) to (0,-0.8) node[gr    │
│   10 │   │   │   │   │   \\end{circuitikz}"""                                                    │
│ ❱ 11 │   │   tex = Tex(circuit, tex_template=myTemplate).scale(3)                                │
│   12 │   │   self.add(tex)                                                                       │
│                                                                                                  │
│ /Users/Coto/Library/Python/3.9/lib/python/site-packages/manim/mobject/svg/tex_mobject.py:410 in  │
│ __init__                                                                                         │
│                                                                                                  │
│   407 │   def __init__(                                                                          │
│   408 │   │   self, *tex_strings, arg_separator="", tex_environment="center", **kwargs           │
│   409 │   ):                                                                                     │
│ ❱ 410 │   │   MathTex.__init__(                                                                  │
│   411 │   │   │   self,                                                                          │
│   412 │   │   │   *tex_strings,                                                                  │
│   413 │   │   │   arg_separator=arg_separator,                                                   │
│                                                                                                  │
│ /Users/Coto/Library/Python/3.9/lib/python/site-packages/manim/mobject/svg/tex_mobject.py:265 in  │
│ __init__                                                                                         │
│                                                                                                  │
│   262 │   │   │   │   tex_template=self.tex_template,                                            │
│   263 │   │   │   │   **kwargs,                                                                  │
│   264 │   │   │   )                                                                              │
│ ❱ 265 │   │   │   self.break_up_by_substrings()                                                  │
│   266 │   │   except ValueError as compilation_error:                                            │
│   267 │   │   │   if self.brace_notation_split_occurred:                                         │
│   268 │   │   │   │   logger.error(                                                              │
│                                                                                                  │
│ /Users/Coto/Library/Python/3.9/lib/python/site-packages/manim/mobject/svg/tex_mobject.py:338 in  │
│ break_up_by_substrings                                                                           │
│                                                                                                  │
│   335 │   │   │   │   # positioned in the right part of the MathTex                              │
│   336 │   │   │   │   sub_tex_mob.set_submobjects([VectorizedPoint()])                           │
│   337 │   │   │   │   last_submob_index = min(curr_index, len(self.submobjects) - 1)             │
│ ❱ 338 │   │   │   │   sub_tex_mob.move_to(self.submobjects[last_submob_index], RIGHT)            │
│   339 │   │   │   else:                                                                          │
│   340 │   │   │   │   sub_tex_mob.set_submobjects(self.submobjects[curr_index:new_index])        │
│   341 │   │   │   new_submobjects.append(sub_tex_mob)                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range