3b1b / manim

Animation engine for explanatory math videos
MIT License
61.91k stars 5.76k forks source link

Using braces #941

Open ghost opened 4 years ago

ghost commented 4 years ago

I'd like to run the code: numeros4 = TexMobject( "\\mathbb{N}", "=", "\\{", "1", ",", "2", ",", "3", ",", "\\ldots", "\\}" ) cause I wish I could change the color of the braces separately. But I got this error: Exception: Latex error converting to dvi. I've already tried using the command Brace() or the ideas found at reddit, but it didn't work at all. Is there a way to make it possible?

Thanks!

Aathish04 commented 4 years ago

Have you installed LaTeX? You also need quite a few LaTeX packages with it as well. Please post the full traceback and we may be able to help you better.

ghost commented 4 years ago

I certainly have. This is the basic LaTeX code, I just wanna write the braces separately.

Here the traceback: Traceback (most recent call last): File "C:\Manim\manim-master\manimlib\extract_scene.py", line 155, in main scene = SceneClass(**scene_kwargs) File "C:\Manim\manim-master\manimlib\scene\scene.py", line 53, in __init__ self.construct() File "1.py", line 170, in construct self.numeros_naturais() File "1.py", line 241, in numeros_naturais "\\}" File "C:\Manim\manim-master\manimlib\mobject\svg\tex_mobject.py", line 153, in __init__ self.break_up_by_substrings() File "C:\Manim\manim-master\manimlib\mobject\svg\tex_mobject.py", line 184, in break_up_by_substrings sub_tex_mob = SingleStringTexMobject(tex_string, **config) File "C:\Manim\manim-master\manimlib\mobject\svg\tex_mobject.py", line 44, in __init__ self.template_tex_file_body File "C:\Manim\manim-master\manimlib\utils\tex_file_writing.py", line 19, in tex_to_svg_file dvi_file = tex_to_dvi(tex_file) File "C:\Manim\manim-master\manimlib\utils\tex_file_writing.py", line 67, in tex_to_dvi "See log output above or the log file: %s" % log_file) Exception: Latex error converting to dvi. See log output above or the log file: ./media\Tex\0447ed74899f41fb.log

Thanks!

Aathish04 commented 4 years ago

Hmm, the traceback points to a log file in ./media\Tex\0447ed74899f41fb.log. Could you please post the contents of that as well?

Also, I've heard people saying that it isn't possible to write a single brace in LaTeX. You use Brace() for that, but you say you have tried that as well.

In any case, the contents of the log file would be mighty helpful.

On 28-Mar-2020, at 17:53, mvfs314 notifications@github.com wrote:

I certainly have. This is the basic LaTeX code, I just wanna write the braces separately.

Here the traceback: Traceback (most recent call last): File "C:\Manim\manim-master\manimlib\extract_scene.py", line 155, in main scene = SceneClass(scene_kwargs) File "C:\Manim\manim-master\manimlib\scene\scene.py", line 53, in init self.construct() File "1.py", line 170, in construct self.numeros_naturais() File "1.py", line 241, in numeros_naturais "\}" File "C:\Manim\manim-master\manimlib\mobject\svg\tex_mobject.py", line 153, in init self.break_up_by_substrings() File "C:\Manim\manim-master\manimlib\mobject\svg\tex_mobject.py", line 184, in break_up_by_substrings sub_tex_mob = SingleStringTexMobject(tex_string, config) File "C:\Manim\manim-master\manimlib\mobject\svg\tex_mobject.py", line 44, in init self.template_tex_file_body File "C:\Manim\manim-master\manimlib\utils\tex_file_writing.py", line 19, in tex_to_svg_file dvi_file = tex_to_dvi(tex_file) File "C:\Manim\manim-master\manimlib\utils\tex_file_writing.py", line 67, in tex_to_dvi "See log output above or the log file: %s" % log_file) Exception: Latex error converting to dvi. See log output above or the log file: ./media\Tex\0447ed74899f41fb.log

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/3b1b/manim/issues/941#issuecomment-605440295, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5H6JBA2UIU6JM4LV7UW6TRJXT35ANCNFSM4LVIZ2FA.

ghost commented 4 years ago

Here all the log file: `This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 2.9.7300 64-bit) (preloaded format=latex 2020.2.25) 28 MAR 2020 09:20 entering extended mode **./media/Tex/0447ed74899f41fb.tex (media/Tex/0447ed74899f41fb.tex LaTeX2e <2020-02-02> patch level 3 L3 programming layer <2020-02-21> ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/standalone\standal one.cls" Document Class: standalone 2018/03/26 v1.3a Class to compile TeX sub-files stan dalone ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/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. ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\ifluatex.s ty" Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead. ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/iftex\iftex.sty" Package: iftex 2019/11/07 v1.0c TeX engine tests )) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/xkeyval\xkeyval.st y" Package: xkeyval 2014/12/03 v2.7a package option processing (HA)

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/xkeyval\xkeyval. tex" ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/xkeyval\xkvutils .tex" \XKV@toks=\toks14 \XKV@tempa@toks=\toks15

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/xkeyval\keyval.t ex")) \XKV@depth=\count167 File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA) )) \sa@internal=\count168 \c@sapage=\count169

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/standalone\standal one.cfg" File: standalone.cfg 2018/03/26 v1.3a Default configuration file for 'standalon e' class ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\article.cls " Document Class: article 2019/12/20 v1.4l Standard LaTeX document class ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\size10.clo" File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option) ) \c@part=\count170 \c@section=\count171 \c@subsection=\count172 \c@subsubsection=\count173 \c@paragraph=\count174 \c@subparagraph=\count175 \c@figure=\count176 \c@table=\count177 \abovecaptionskip=\skip47 \belowcaptionskip=\skip48 \bibindent=\dimen134 ) ("C:\Program Files\MiKTeX 2.9\tex/latex\preview\preview.sty" Package: preview 2017/04/24 11.91 (AUCTeX/preview-latex)

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/luatex85\luatex8 5.sty" Package: luatex85 2016/06/15 v1.4 pdftex aliases for luatex ) ("C:\Program Files\MiKTeX 2.9\tex/latex\preview\prtightpage.def" \PreviewBorder=\dimen135 ) \pr@snippet=\count178 \pr@box=\box45 \pr@output=\toks16 )) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/babel\babel.s ty" Package: babel 2020/02/14 3.40 The Babel package ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/babel\switch.def " File: switch.def 2020/02/14 3.40 Babel switching mechanism )


("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/generic/babel\txtbabel.d ef") \bbl@readstream=\read2 \bbl@dirlevel=\count180 ) Package babel Info: \l@canadian = using hyphenrules for english (babel) (\language0) on input line 102. Package babel Info: \l@australian = using hyphenrules for ukenglish (babel) (\language77) on input line 105. Package babel Info: \l@newzealand = using hyphenrules for ukenglish (babel) (\language77) on input line 108. )) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\inputenc.s ty" Package: inputenc 2018/08/11 v1.3c Input encoding file \inpenc@prehook=\toks17 \inpenc@posthook=\toks18 ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\fontenc.sty " Package: fontenc 2020/02/11 v2.0o Standard LaTeX package ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsmath\amsmath.st y" Package: amsmath 2020/01/20 v2.17e AMS math features \@mathmargin=\skip49 For additional information on amsmath, use the `?' option.

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsmath\amstext.st y" Package: amstext 2000/06/29 v2.01 AMS text ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsmath\amsgen.sty " File: amsgen.sty 1999/11/30 v2.0 generic functions \@emptytoks=\toks19 \ex@=\dimen137 )) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsmath\amsbsy. sty" Package: amsbsy 1999/11/29 v1.2d Bold Symbols \pmbraise@=\dimen138 ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsmath\amsopn.s ty" Package: amsopn 2016/03/08 v2.02 operator names ) \inf@bad=\count181 LaTeX Info: Redefining \frac on input line 227. \uproot@=\count182 \leftroot@=\count183 LaTeX Info: Redefining \overline on input line 389. \classnum@=\count184 \DOTSCASE@=\count185 LaTeX Info: Redefining \ldots on input line 486. LaTeX Info: Redefining \dots on input line 489. LaTeX Info: Redefining \cdots on input line 610. \Mathstrutbox@=\box46 \strutbox@=\box47 \big@size=\dimen139 LaTeX Font Info: Redeclaring font encoding OML on input line 733. LaTeX Font Info: Redeclaring font encoding OMS on input line 734. \macc@depth=\count186 \c@MaxMatrixCols=\count187 \dotsspace@=\muskip16 \c@parentequation=\count188 \dspbrk@lvl=\count189 \tag@help=\toks20 \row@=\count190 \column@=\count191 \maxfields@=\count192 \andhelp@=\toks21 \eqnshift@=\dimen140 \alignsep@=\dimen141 \tagshift@=\dimen142 \tagwidth@=\dimen143 \totwidth@=\dimen144 \lineht@=\dimen145 \@envbody=\toks22 \multlinegap=\skip50 \multlinetaggap=\skip51 \mathdisplay@stack=\toks23 LaTeX Info: Redefining [ on input line 2859. LaTeX Info: Redefining ] on input line 2860. ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsfonts\amssymb.s ty" Package: amssymb 2013/01/14 v3.01 AMS font symbols

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsfonts\amsfonts. 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 versionbold' (Font) U/euf/m/n --> U/euf/b/n on input line 106. )) ("C:\Program Files\MiKTeX 2.9\tex/latex\doublestroke\dsfont.sty" Package: dsfont 1995/08/01 v0.1 Double stroke roman fonts ) ("C:\Program Files\MiKTeX 2.9\tex/latex\setspace\setspace.sty" Package: setspace 2011/12/19 v6.7a set line spacing ) ("C:\Program Files\MiKTeX 2.9\tex/latex\tipa\tipa.sty" Package: tipa 2002/08/08 TIPA version 1.1 ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\fontenc.sty" Package: fontenc 2020/02/11 v2.0o Standard LaTeX package ("C:\Program Files\MiKTeX 2.9\tex/latex\tipa\t3enc.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+cmss on input line 3 57. ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\t1cmss.fd" File: t1cmss.fd 2019/12/16 v2.5j Standard LaTeX font definitions )))) ("C:\Program Files\MiKTeX 2.9\tex/latex\relsize\relsize.sty" Package: relsize 2013/03/29 ver 4.1 ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/base\textcomp.st y" Package: textcomp 2020/02/02 v2.0n Standard LaTeX package ) ("C:\Program Files\MiKTeX 2.9\tex/latex\jknappen\mathrsfs.sty" Package: mathrsfs 1996/01/01 Math RSFS package v1.0 (jk) \symrsfs=\mathgroup6 ) ("C:\Program Files\MiKTeX 2.9\tex/latex\fundus-calligra\calligra.sty" Package: calligra 2012/04/10 v1.9 LaTeX package calligra ) ("C:\Program Files\MiKTeX 2.9\tex/latex\wasysym\wasysym.sty" Package: wasysym 2020/01/19 v2.4 Wasy-2 symbol support package \symwasy=\mathgroup7 LaTeX Font Info: Overwriting symbol font wasy' in versionbold' (Font) U/wasy/m/n --> U/wasy/b/n on input line 93. ) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/ragged2e\ragged2e. sty" Package: ragged2e 2019/07/28 v2.2 ragged2e Package (MS) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/ms\everysel.sty" Package: everysel 2011/10/28 v1.2 EverySelectfont Package (MS) ) \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:\Program Files\MiKTeX 2.9\tex/latex\physics\physics.sty" Package: physics

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/l3packages/xparse\ xparse.sty" ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/l3kern el\expl3.sty" Package: expl3 2020-02-21 L3 programming layer (loader)

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/l3backend\l3backen d-dvips.def" File: l3backend-dvips.def 2020-02-23 L3 backend support: dvips \lpdf_internal_box=\box48 \gpdf_backend_object_int=\count193 \lpdf_backend_content_box=\box49 \l__pdf_backend_model_box=\box50 \gpdf_backend_annotation_int=\count194 \gpdf_backend_link_int=\count195 \gpdf_backend_link_sf_int=\count196 )) Package: xparse 2020-02-14 L3 Experimental document command parser \lxparse_current_arg_int=\count197 \gxparse_grabber_int=\count198 \l__xparse_m_args_int=\count199 \l__xparse_v_nesting_int=\count266 )) ("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/xcolor\xcolor.s ty" Package: xcolor 2016/05/11 v2.12 LaTeX color extensions (UK)

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-cfg\color .cfg" File: color.cfg 2016/01/02 v1.6 sample color configuration ) Package xcolor Info: Driver file: dvips.def on input line 225.

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/graphics-def\dvips .def" File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips ) Package xcolor Info: Model cmy' substituted bycmy0' on input line 1348. Package xcolor Info: Model RGB' extended on input line 1364. Package xcolor Info: ModelHTML' substituted by rgb' on input line 1366. Package xcolor Info: ModelHsb' substituted by hsb' on input line 1367. Package xcolor Info: ModeltHsb' substituted by hsb' on input line 1368. Package xcolor Info: ModelHSB' substituted by hsb' on input line 1369. Package xcolor Info: ModelGray' substituted by gray' on input line 1370. Package xcolor Info: Modelwave' substituted by `hsb' on input line 1371. ) ("C:\Program Files\MiKTeX 2.9\tex/latex\microtype\microtype.sty" Package: microtype 2019/11/18 v2.7d Micro-typographical refinements (RS) \MT@toks=\toks24 \MT@count=\count267 LaTeX Info: Redefining \textls on input line 790. \MT@outer@kern=\dimen146 LaTeX Info: Redefining \textmicrotypecontext on input line 1354. \MT@listname@count=\count268 ("C:\Program Files\MiKTeX 2.9\tex/latex\microtype\microtype-pdftex.def" File: microtype-pdftex.def 2019/11/18 v2.7d Definitions specific to pdftex (RS)

LaTeX Info: Redefining \lsstyle on input line 914. LaTeX Info: Redefining \lslig on input line 914. \MT@outer@space=\skip66 ) Package microtype Info: Loading configuration file microtype.cfg. ("C:\Program Files\MiKTeX 2.9\tex/latex\microtype\microtype.cfg" File: microtype.cfg 2019/11/18 v2.7d microtype main configuration file (RS) )) (C:\Manim\manim-master\media\Tex\0447ed74899f41fb.aux) \openout1 = `0447ed74899f41fb.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:\Program Files\MiKTeX 2.9\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. ("C:\Program Files\MiKTeX 2.9\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 U+msa on input line 26.

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsfonts\umsa.fd" File: umsa.fd 2013/01/14 v3.01 AMS symbols A ) ("C:\Program Files\MiKTeX 2.9\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.

("C:\Users\mvfs3\AppData\Local\Programs\MiKTeX 2.9\tex/latex/amsfonts\umsb.fd" File: umsb.fd 2013/01/14 v3.01 AMS symbols B ) ("C:\Program Files\MiKTeX 2.9\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 . ("C:\Program Files\MiKTeX 2.9\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 . ("C:\Program Files\MiKTeX 2.9\tex/latex\wasysym\uwasy.fd" File: uwasy.fd 2020/01/19 v2.4 Wasy-2 symbol font definitions ) ! Argument of \align* has an extra }.

\par l.27 \{} Here is how much of TeX's memory you used: 7327 strings out of 481508 111190 string characters out of 2912081 392778 words of memory out of 3000000 22471 multiletter control sequences out of 15000+200000 538995 words of font info for 43 fonts, out of 3000000 for 9000 1141 hyphenation exceptions out of 8191 43i,3n,60p,354b,212s stack positions out of 5000i,500n,10000p,200000b,50000s No pages of output. `
ghost commented 4 years ago

And, about the Braces() it's not very useful when I want to use in a single text line :/

Aathish04 commented 4 years ago

This appears to be a LaTeX specific problem.

You simply cannot use a single brace separately in LaTeX, and the way manim renders LaTeX (it uses \align a lot), the parser keeps thinking it is seeing a single brace.

For the time being, i suggest you use two Brace()es, which is tedious, but perhaps someone more experienced with LaTeX can help you out.

If you feel like probing the problem deeper, you can modify tex_template.tex, and see if you can get it to work.

All the best ;)

NavpreetDevpuri commented 4 years ago

in LaTeX you can't use a single curly bracket. means you can't create TextMobject(" \\{") or TextMobject(" \\}") or TextMobject(" \\{aaa") but you can use a SVG image to print '{' or '}'. Now, create two files 'LeftCurlyBracket.svg'

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 136 324" style="enable-background:new 0 0 136 324;" xml:space="preserve">
<g id="_x23_ffffffff">
    <path d="M72.6,18.3c13.6-9.2,30.4-13,46.6-12.8c4-0.6,6.5,5.8,1.9,6.7c-9.4,0.7-19.2,2.5-27,8.2c-9.7,6.6-14.8,18.5-14.9,30
        c-0.1,19.4,0,38.7,0,58.1c0,8.5,1.2,17.3-1.6,25.5c-2.3,7.6-7.9,13.9-14.5,18c-6.6,4.2-13.9,7-21.1,9.9
        c10.5,3.3,21.4,7.5,28.6,16.3c5.5,6.4,8.7,14.8,8.9,23.3c-0.5,25.2-0.2,50.4-0.2,75.5c-0.3,9,4.3,17.6,11,23.4
        c8.4,7.3,19.5,10.7,30.4,11.2c4.7,0.5,2.8,7.2-1.3,6.8c-13.7,0.2-27.7-2.4-40-8.5c-9.2-4.6-17.3-12.3-20.4-22.3
        c-2-7.2-1.6-14.8-1.7-22.2c0-21.7,0.1-43.4-0.1-65.1c-0.4-14.8-11.8-27.6-25.5-32.2c-6.4-2.1-13.6-1.4-19.4-5
        c0.5-1.6,0.6-3.9,2.7-4.2c11.3-1.8,23.3-4.5,31.9-12.6c7.2-6.7,10.2-16.7,10.3-26.3c0.2-24.6-0.2-49.2,0.2-73.8
        C57.6,35.2,63.3,24.5,72.6,18.3z"/>
</g>
</svg>

'RightCurlyBracket.svg'

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 136 324" style="enable-background:new 0 0 136 324;" xml:space="preserve">
<g id="_x23_ffffffff">
    <path d="M72.6,18.3c13.6-9.2,30.4-13,46.6-12.8c4-0.6,6.5,5.8,1.9,6.7c-9.4,0.7-19.2,2.5-27,8.2c-9.7,6.6-14.8,18.5-14.9,30
        c-0.1,19.4,0,38.7,0,58.1c0,8.5,1.2,17.3-1.6,25.5c-2.3,7.6-7.9,13.9-14.5,18c-6.6,4.2-13.9,7-21.1,9.9
        c10.5,3.3,21.4,7.5,28.6,16.3c5.5,6.4,8.7,14.8,8.9,23.3c-0.5,25.2-0.2,50.4-0.2,75.5c-0.3,9,4.3,17.6,11,23.4
        c8.4,7.3,19.5,10.7,30.4,11.2c4.7,0.5,2.8,7.2-1.3,6.8c-13.7,0.2-27.7-2.4-40-8.5c-9.2-4.6-17.3-12.3-20.4-22.3
        c-2-7.2-1.6-14.8-1.7-22.2c0-21.7,0.1-43.4-0.1-65.1c-0.4-14.8-11.8-27.6-25.5-32.2c-6.4-2.1-13.6-1.4-19.4-5
        c0.5-1.6,0.6-3.9,2.7-4.2c11.3-1.8,23.3-4.5,31.9-12.6c7.2-6.7,10.2-16.7,10.3-26.3c0.2-24.6-0.2-49.2,0.2-73.8
        C57.6,35.2,63.3,24.5,72.6,18.3z"/>
</g>
</svg>

Save those files to the media directory 'manim\assets\svg_images' Now create a single character temp_char = TextMobject("(") just for getting character's width or height. After that you can create a single character '{' or '}' like following code.

temp_char = TextMobject("(")
text = TextMobject("any text")
if char == "{":
    cb = SVGMobject("LeftCurlyBracket.svg", color=RED).set_height(temp_char.get_height())
else:
    cb = SVGMobject("RightCurlyBracket.svg", color=RED).set_height(temp_char.get_height())
#you can place it at the end of text as follow
cb.move_to(text.get_right()+np.array([self.temp_char.get_width()*2, 0, 0]))
self.play(Write(text))
self.play(Write(cb),run_time=0.3)

Or you can use Brace() you can use "width_multiplier" to make Braces looks normal

temp_char = TextMobject("(")
cb = Brace(temp_char,LEFT,width_multiplier=8)
text = TextMobject("any text")
cb.move_to(text.get_right()+np.array([self.temp_char.get_width()*2, 0, 0]))
self.play(Write(text))
self.play(Write(cb),run_time=0.3)

i created a method that returns appropriate width_multiplier according to text_scale_factor.

def get_braces_scale_factor_acc_to_text_scale_factor(text_scale_factor):
    if text_scale_factor <= 0.6:
        return 9
    elif 0.6 < text_scale_factor <=1:
        return 6.5
    elif 1 < text_scale_factor <=1.5:
        return 5
    elif 1.5 < text_scale_factor <= 2:
        return 3.5
    elif 2<text_scale_factor<=2.5:
        return 2.5
    elif 2.5<text_scale_factor:
        return 2

you can use it like

text = TextMobject("any text").scale(3)
cb = Brace(temp_char,LEFT,width_multiplier=get_braces_scale_factor_acc_to_text_scale_factor(3))

it don't work for text_scale_factor less than 0.5 so you can rescale windows's size by following code

fh = 17.0 #this is number of coordinates along y-axis (move_to(np.array([x,y,0])))
fw = fh * DEFAULT_PIXEL_WIDTH / DEFAULT_PIXEL_HEIGHT
class codex(Scene):
    CONFIG = {
        "camera_config":
            {"frame_height": fh,
             "frame_width": fw, }
    }
    def construct(self):
        text = TextMobject("any text").scale(3)
        cb = Brace(temp_char,LEFT,width_multiplier=get_braces_scale_factor_acc_to_text_scale_factor(3))
NavpreetDevpuri commented 4 years ago

use Text("{") instead of TextMobject("{") after that place it where ever you want to.

temp_char = TextMobject("(")
cb =TextMobject("{")
text = TextMobject("any text")
cb.move_to(text.get_right()+np.array([self.temp_char.get_width()*2, 0, 0]))
NavpreetDevpuri commented 4 years ago
class colorBetterApproach(Scene):
    def construct(self):
        # if you want to color "{" or "}" braces character separately
        numeros4 = TexMobject( "\\mathbb{N}=\\{1,2,3,\\ldots\\}")
        # coloring first 2 characters 
        numeros4[0][0:2].set_color(GREEN)
        # coloring 3rd character
        numeros4[0][2].set_color(RED)
        self.add(numeros4)
        self.wait()

Output 3_text_like_arrays_better_approach

somilbhandari commented 4 years ago

I was able to use single curly brace in single line with custom color using Brace() and dummy text.

See if this helps you

class brace_example(Scene):
    def construct(self):
        text1 = TextMobject("text1")
        dummy = TextMobject("dummy")
        dummy.next_to(text1, RIGHT)
        dummy.shift(0.5 * RIGHT)

        braces=Brace(dummy,LEFT)
        braces.set_color(RED)

        self.play(Write(text1),  Write(braces))

        dummy2 = TextMobject("dummy")
        braces=Brace(dummy2, RIGHT)
        braces.next_to(text1, DOWN)
        text2 = TextMobject("text2")
        text2.next_to(braces, RIGHT)
        braces.set_color(YELLOW)

        self.play(Write(braces))
        self.play(Write(text2))