Historique des modifications [retour]
cliquez ici pour masquer/afficher la révision 2

11 Déc '19, 22:20

christophe-poulain's gravatar image

christophe-poulain
8661827

Bon, j'ai suivi vos idées en recréant une accolade sous metapost :) :). J'ai adapté le code trouvé ici : https://tex.stackovernet.com/fr/q/67363 Voici le code : \documentclass{article} \usepackage[shellescape]{gmp} \begin{document} \begin{mpost} prologues:=2; u:=1cm; vardef braceh_label(expr s,a,b) text t_ = save m,theta; pair m; theta := angle (b-a); m := .5[a,b]+(10 up rotated theta); label.top(s,m) rotatedabout(m, theta) t_; draw (a+(1 left + 5 down)){dir (90-theta)} .. a+(2 up rotated theta) { dir (60+theta) } .. a+((6,6) rotated theta) -- m+((-6,-4) rotated theta) .. { dir (60+theta) } m { dir (theta-60) } .. m+((+6,-4) rotated theta) -- b+((-6,6) rotated theta) .. { dir (theta-60) } b+(2 up rotated theta) .. { dir (theta-90) } b+(1 right+5down) withpen pencircle scaled .4 t_; enddef; vardef braceb_label(expr s,a,b) text t_ = save m,theta; pair m; theta := angle (b-a); m := .5[a,b]+(10 down rotated -theta); label.bot(s,m) rotatedabout(m, theta) t_; draw (a+(1 left + 5 up)){dir (-90+theta)} .. a+(2 down rotated -theta) { dir (-60-theta) } .. a+((6,-6) rotated -theta) -- m+((-6,4) rotated -theta) .. { dir (-60-theta) } m { dir (-theta+60) } .. m+((+6,4) rotated -theta) -- b+((-6,-6) rotated -theta) .. { dir (-theta+60) } b+(2 down rotated -theta) .. { dir (-theta+90) } b+(1 right+5 up) withpen pencircle scaled .4 t_; enddef; vardef Bloc(expr tt)= save Bb; if numeric tt: path Bb; Bb=u*(-0.5,-0.25)--u*(0.5,-0.25)--u*(0.5,0.25)--u*(-0.5,0.25)--cycle; elseif picture tt: picture Bb; Bb=tt; fi; Bb enddef; boolean visible[]; visible1=false; visible2=false; visible3=false; vardef Groupe(expr base,aa,bb,cc,op)=%base est une paire; a,b,c les composants, op l'opération sous forme classique save $; picture $; pair Base[]; Base1=base+u*(-1.5,0.85); Base2=base+u*(0,0.85); Base3=2[Base1,Base2]; $=image( draw Bloc(aa) shifted Base1; draw Bloc(bb) shifted Base3; draw Bloc(cc) shifted base; if op="m": label(btex $\times$ etex,Base2); fi; if op="a": label(btex $+$ etex,Base2); fi; if op="s": label(btex $-$ etex,Base2); fi; if op="d": label(btex $\div$ etex,Base2); fi; if visible1: if numeric aa: label(""&decimal(aa)&"",Base1); fi; fi; if visible2: if numeric bb: label(""&decimal(bb)&"",Base3); fi; fi; if visible3: if numeric cc: label(""&decimal(cc)&"",base); fi; fi; braceb_label("",Base1+u*(-0.6,-0.15),Base3+u*(0.6,-0.15)); ); $ enddef; beginfig(1); picture BB[]; visible1:=true; visible2:=true; BB1=Groupe(u*(0,0),2,3,6,"m"); visible1:=false; BB2=Groupe(u*(0,0),BB1,5,3,"a"); BB3=Groupe(u*(0,0),20,BB2,3,"s"); draw BB3; endfig; end \end{mpost} \end{document}
cliquez ici pour masquer/afficher la révision 1

11 Déc '19, 22:14

christophe-poulain's gravatar image

christophe-poulain
8661827

Bon, j'ai suivi vos idées en recréant une accolade sous metapost :) Voici le code : \documentclass{article} \usepackage[shellescape]{gmp} \begin{document} \begin{mpost} prologues:=2; u:=1cm; vardef braceh_label(expr s,a,b) text t_ = save m,theta; pair m; theta := angle (b-a); m := .5[a,b]+(10 up rotated theta); label.top(s,m) rotatedabout(m, theta) t_; draw (a+(1 left + 5 down)){dir (90-theta)} .. a+(2 up rotated theta) { dir (60+theta) } .. a+((6,6) rotated theta) -- m+((-6,-4) rotated theta) .. { dir (60+theta) } m { dir (theta-60) } .. m+((+6,-4) rotated theta) -- b+((-6,6) rotated theta) .. { dir (theta-60) } b+(2 up rotated theta) .. { dir (theta-90) } b+(1 right+5down) withpen pencircle scaled .4 t_; enddef; vardef braceb_label(expr s,a,b) text t_ = save m,theta; pair m; theta := angle (b-a); m := .5[a,b]+(10 down rotated -theta); label.bot(s,m) rotatedabout(m, theta) t_; draw (a+(1 left + 5 up)){dir (-90+theta)} .. a+(2 down rotated -theta) { dir (-60-theta) } .. a+((6,-6) rotated -theta) -- m+((-6,4) rotated -theta) .. { dir (-60-theta) } m { dir (-theta+60) } .. m+((+6,4) rotated -theta) -- b+((-6,-6) rotated -theta) .. { dir (-theta+60) } b+(2 down rotated -theta) .. { dir (-theta+90) } b+(1 right+5 up) withpen pencircle scaled .4 t_; enddef; vardef Bloc(expr tt)= save Bb; if numeric tt: path Bb; Bb=u*(-0.5,-0.25)--u*(0.5,-0.25)--u*(0.5,0.25)--u*(-0.5,0.25)--cycle; elseif picture tt: picture Bb; Bb=tt; fi; Bb enddef; boolean visible[]; visible1=false; visible2=false; visible3=false; vardef Groupe(expr base,aa,bb,cc,op)=%base est une paire; a,b,c les composants, op l'opération sous forme classique save $; picture $; pair Base[]; Base1=base+u*(-1.5,0.85); Base2=base+u*(0,0.85); Base3=2[Base1,Base2]; $=image( draw Bloc(aa) shifted Base1; draw Bloc(bb) shifted Base3; draw Bloc(cc) shifted base; if op="m": label(btex $\times$ etex,Base2); fi; if op="a": label(btex $+$ etex,Base2); fi; if op="s": label(btex $-$ etex,Base2); fi; if op="d": label(btex $\div$ etex,Base2); fi; if visible1: if numeric aa: label(""&decimal(aa)&"",Base1); fi; fi; if visible2: if numeric bb: label(""&decimal(bb)&"",Base3); fi; fi; if visible3: if numeric cc: label(""&decimal(cc)&"",base); fi; fi; braceb_label("",Base1+u*(-0.6,-0.15),Base3+u*(0.6,-0.15)); ); $ enddef; beginfig(1); picture BB[]; visible1:=true; visible2:=true; BB1=Groupe(u*(0,0),2,3,6,"m"); visible1:=false; BB2=Groupe(u*(0,0),BB1,5,3,"a"); BB3=Groupe(u*(0,0),20,BB2,3,"s"); draw BB3; endfig; end \end{mpost} \end{document}

C'est votre première visite ici ? Consultez la FAQ !

×