Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support tikz,tikz-cd,includegraphics #2058

Closed
wants to merge 0 commits into from

Conversation

germanzhu
Copy link

Motivation

Manim is not correctly drawing tikzpictures

Proposed changes

  • svg_mobject.py
  • tex_file_writing.py

Test

Code:

from manimlib import *


class Video(Scene):
    
    def construct(self):
        
        txt = r"""
\begin{tikzcd}
    {\mathcal{C}}
    \arrow["K"', from=1-1, to=2-1]
    \arrow[bend left=37, "F" name=U, from=1-1, to=2-2] 
    \arrow[Rightarrow, "\eta" description, 
    shorten <=4pt, pos=0.58, from=U, to=2-1] \\
    {\mathcal{D}}
    \arrow["\mathrm{Lan}_K F"', ""{name=UU, below},
    from=2-1, to=2-2] & {\mathcal{E}}  \\
    {\quad } & {\quad }
    \arrow[phantom, ""{coordinate,name=Z}, 
    from=3-1, to=3-2]
    \arrow["L"', ""{name=DD}, 
     from=2-1, to= 2-2, 
     rounded corners,
    to path={ -- ([yshift=-3ex] \tikztostart.south)
              |- (Z) [pos=1] \tikztonodes
              -| ([yshift=-3ex] \tikztotarget.south)
              -- (\tikztotarget)}] 
    \arrow ["\chi", Rightarrow,  shorten <=1.5pt,
    from=UU, to= DD, yshift=-1ex]
\end{tikzcd}
        """
        
        tex = TexText(txt, template="ctex",additional_preamble=r"\usepackage{tikz-cd}").set_stroke(RED,width=4)
        self.play(ShowCreation(tex),run_time=10)

Result:

Video.mp4

@3b1b
Copy link
Owner

3b1b commented Sep 6, 2024

Thanks for the proposed fix, but this doesn't seem to work for me. Specifically at this line, (in svg_mobjct.py, at line 122)

element_tree = ET.parse(file_path)

It doesn't seem to find the given file path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants