cpierquet

latexenvxcas

Jan 3rd, 2021 (edited)
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 3.95 KB | None | 0 0
  1. \makeatletter
  2.  
  3. % ========= DEF DES CLES PARAM FENETRES XCAS =========
  4. \define@key{paramwinxcas}{color}{\def\xcas@color{#1}} %couleur des traits
  5. \define@key{paramwinxcas}{larg}{\def\xcas@larg{#1}} %largeur de la fenêtre
  6. \define@key{paramwinxcas}{esplg}{\def\xcas@esplg{#1}} %espacement entre lignes
  7. \define@key{paramwinxcas}{premcol}{\def\xcas@premcol{#1}} %largeur encadré numéro
  8. \define@key{paramwinxcas}{hpremcol}{\def\xcas@hpremcol{#1}} %hauteur encadré numéro
  9. % ========= CLES PAR DEFAUT =========
  10. \setkeys{paramwinxcas}{larg=16,esplg=2pt,premcol=0.3,hpremcol=0.4,color=darkgray}
  11. % ========= COMMANDES DEF PARAM WINDOW XCAS =========
  12. \newcommand\paramxcas[1][]{%
  13.     \setkeys{paramwinxcas}{#1}% on paramètres les nouvelles clés
  14.     \def\larg{\xcas@larg}
  15.     \def\esplg{\xcas@esplg}
  16.     \def\premcol{\xcas@premcol}
  17.     \def\hpremcol{\xcas@hpremcol}
  18.     }
  19.  
  20. % ========= DEF DES CLES PARAM LIGNES XCAS =========
  21. \define@key{paramlgxcas}{num}{\def\xcas@num{#1}} %numéro de la commande
  22. \define@key{paramlgxcas}{hc}{\def\xcas@hc{#1}} %hauteur de la ligne commande
  23. \define@key{paramlgxcas}{hr}{\def\xcas@hr{#1}} %hauteur de la ligne résultat
  24. % ========= CLES PAR DEFAUT =========
  25. \setkeys{paramlgxcas}{num=1,hc=0.75,hr=0.75}
  26.  
  27. \newcommand{\lignexcasinit}[3][]{%
  28.     \setkeys{paramlgxcas}{#1}% on paramètres les nouvelles clés
  29.     \def\L{\xcas@num}
  30.     \def\hle{\xcas@hc}
  31.     \def\hlr{\xcas@hr}
  32.     \coordinate (A01) at (0,0);
  33.     \coordinate (A11) at ($(A01) + (0,{-\hle})$);
  34.     \coordinate (A21) at ($(A11) + (0,{-\hlr})$);
  35.     \coordinate (A31) at ($(A11) + ({\larg},0)$);
  36.     \coordinate (A41) at ($(A21) + ({\larg},0)$);
  37.     \draw[\xcas@color] (A01) rectangle (A31) ;
  38.     \draw ($(A0\L) + (0,{-0.5*\hle})$) node[red,right,font=\large\sf] {#2} ;
  39.     \draw[\xcas@color] (A11) rectangle (A41) node[midway,blue,font=\large\sf] {#3} ;
  40.     \draw[\xcas@color] (A01) rectangle ++ ({-\premcol},{-\hpremcol}) node[\xcas@color,midway] {\small \sf \bfseries \L} ;
  41.     \draw[\xcas@color,fill=\xcas@color!33] (A41) rectangle ++ (-0.75,0.25) node[black,midway] {\tiny \sf \bfseries MENU} ;
  42.     }
  43.  
  44. \newcommand{\lignexcas}[3][]{%
  45.     \setkeys{paramlgxcas}{#1}% on paramètres les nouvelles clés
  46.     \def\L{\xcas@num}
  47.     \def\hle{\xcas@hc}
  48.     \def\hlr{\xcas@hr}
  49.     \FPeval{LA}{\L-1}
  50.     \ifthenelse{\equal{\L}{1}}%si c'est la première ligne
  51.         {\coordinate (A0\L) at (0,0);}%
  52.         {\coordinate (A0\L) at ($(A2\LA) + (0,{-\esplg})$);}
  53.     \coordinate (A1\L) at ($(A0\L) +  (0,{-\hle})$);
  54.     \coordinate (A2\L) at ($(A1\L) +  (0,{-\hlr})$);
  55.     \coordinate (A3\L) at ($(A1\L) +  ({\larg},0)$);
  56.     \coordinate (A4\L) at ($(A2\L) +  ({\larg},0)$);
  57.     \draw[\xcas@color] (A0\L) rectangle (A3\L) ;
  58.     \draw ($(A0\L) + (0,{-0.5*\hle})$) node[red,right,font=\large\sf] {#2} ;
  59.     \draw[\xcas@color] (A1\L) rectangle (A4\L) node[midway,blue,font=\large\sf] {#3} ;
  60.     \draw[\xcas@color] (A0\L) rectangle ++ ({-\premcol},{-\hpremcol}) node[\xcas@color,midway] {\small \sf \bfseries \L} ;
  61.     \draw[\xcas@color,fill=\xcas@color!33] (A4\L) rectangle ++ (-0.75,0.25) node[black,midway] {\tiny \sf \bfseries MENU} ;
  62.     }
  63.  
  64. \makeatother
  65.  
  66. \begin{center}
  67.     \begin{tikzpicture}[x=1cm,y=1cm,line width=1pt]
  68.         \paramxcas[larg=16,esplg=2pt,color=purple]
  69.         \lignexcas{Dérivée[(x+5)*exp(-0.1*x)]}{$\mathsf{\rightarrow (0.5-0.1*x)*exp(-0.1*x)}$}
  70.         \lignexcas[num=2]{Dérivée[(x+5)*exp(-0.1*x)]}{$\mathsf{\rightarrow (0.5-0.1*x)*exp(-0.1*x)}$}
  71.         \lignexcas[num=3,hc=1,hr=1]{Dérivée[(x+5)*exp(-0.1*x)]}{$\mathsf{\rightarrow (0.5-0.1*x)*exp(-0.1*x)}$}
  72.         \lignexcas[num=4,hc=1.25,hr=1.5]{COMMANDE4}{RÉSULTAT4}
  73.     \end{tikzpicture}
  74. \end{center}
  75.  
  76. \begin{center}
  77.     \begin{tikzpicture}[x=1cm,y=1cm,line width=1pt]
  78.         \paramxcas[larg=13,esplg=0pt]
  79.         \lignexcas{Dérivée[(x+5)*exp(-0.1*x)]}{$\mathsf{\rightarrow (0.5-0.1*x)*exp(-0.1*x)}$}
  80.         \lignexcas[num=2]{Dérivée[(x+5)*exp(-0.1*x)]}{$\mathsf{\rightarrow (0.5-0.1*x)*exp(-0.1*x)}$}
  81.         \lignexcas[num=3]{Dérivée[(x+5)*exp(-0.1*x)]}{$\mathsf{\rightarrow (0.5-0.1*x)*exp(-0.1*x)}$}
  82.         \lignexcas[num=4]{COMMANDE4}{RÉSULTAT4}
  83.     \end{tikzpicture}
  84. \end{center}
Add Comment
Please, Sign In to add comment