Stage LATEX 2008
Transcription
Stage LATEX 2008
Stage LATEX 2008 PSTricks Jean Pierre Casteleyn 1 1 Introduction 1.1 Avantages – Le dessin est compilé en même temps que le document. – C’est un outil extrêmement puissant : je ne ferai qu’effleurer ici les possibilités de PSTricks. – C’est un outil extrêmement précis : tout est dimensionné à l’aide de paramètres modifiables. – C’est un outil extrêmement souple : Insertion possible d’éléments LATEX dans le dessin et vice versa. – Il possède de nombreuses extensions spécialisées. – Interactions possibles entre le texte et dessin. 2 1.2 Inconvénients – Outil non-wysiwyg 1 : plusieurs compilations sont nécessaires pour finaliser un dessin – La compilation en document pdf n’est pas directe. PSTricks a été conçu pour créer des documents en PostScript : il crée un fichier avec l’extension ps 2 – On peut paramétrer son compilateur pour qu’il convertisse le fichier xxx.ps automatiquement en fichier xxx.pdf. – Le logiciel « GSView » permet de convertir le document au format pdf. 1. wysiwyg :What You See Is What You Get 2. Ce fichier peut être visualisé grâce au programme libre « GSView » 3 2 Premiers pas avec PSTricks 2.1 Chargement de PSTricks Exemple de préambule pour un document \documentclass[12pt,a4paper]{article} \usepackage[frenchb]{babel} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage{textcomp} \usepackage{fp,fullpage} \usepackage{xkeyval} \usepackage{amsmath} % \usepackage{pst-all} %les modules de base % \usepackage{pstricks-add} %un ensemble d’amélioration % %exemple de modules spécialises \usepackage{pst-func} % tracer de fonction \usepackage{pst-3dplot} % courbe en 3D \usepackage{pst-circ} % création de circuits électriques \usepackage{pst-eucl} % Géométrie % Pour information : Le « package pst-all » installe les modules suivants : pstricks , pst-grad, pst-plot, pst-coil, pst-text, pst-char, pst-node, pst-3d, pst-eps, pst-fill, pst-tree et multido A la page suivante, vous trouverez la liste officielle des extensions de PSTricks. Ces extensions sont en perpétuelle amélioration et de nouvelles extensions sont ajoutées ( j’ai repéré en gras les nouvelles extensions créées depuis l’année passée) 4 pst-3d pst-3dplot pst-2dplot PSTricks-add pst-abspos pst-asr pst-bar pst-barcode pst-blur pst-calendar pst-circ pst-coil pst-cox pst-dbicons pst-eps pst-eucl pst-fill pst-fr3d pst-fractal pst-fun pst-func pst-geo pst-gr3d pst-grad pst-infixplot pst-jtree pst-labo pst-lens pst-light3d pst-math pst-node pst-ob3d pst-optexp pst-optic pst-osci pst-pad pst-pdf pst-pdgr pst-plot pst-poly pst-qtree pst-slpe pst-solide3d pst-soroban pst-stru pst-text pst-tree pst-uml pst-vue3d PSTricks The basic PSTricks package PSTricks package for basic 3D operations Three dimensional plots Doc Matlab compatible plots Additional macros for PSTricks/pst-node/pst-plot Putting Objects at absolute Coordinates ne fait pas partie de MiKTEX Linguistic : autosegmental representations PSTricks package for bar charts PSTricks package for printing barcodes PSTricks package for "blurred" shadows Calendras as tabular or on a dodecaeder PSTricks package for electrical circuits PSTricks package for drawing coils Drawing regular complex polytopes PSTricks package for data base structures (entity relation ships) PSTricks package to save environments as eps file Geometrie for LATEX with PSTricks PSTricks package for filling Three dimensional framed Boxes PSTricks package for fractals Plotting special funny images Plotting special math functions PSTricks package for Geographical Objects PSTricks package for 3D grids PSTricks package for gradient colors PSTricks package for math expressions in algebraic notation typesetting of trees that are common in linguistics drawing various assemblies of chemical objects Using a lens to magnify parts of a text or a graphic PSTricks package for 3d light effects PSTricks package for extended mathematical operators PSTricks package for nodes A PSTricks package for three dimensional basic objects Experimental optical systems with PSTricks Optical systems with PSTricks Oscilloscopes with PSTricks drawing attachment mechanisms PostScript into PDF Macros for plotting medical pedigrees Macros for plotting functions and data records Polygons with PSTricks PSTricks package for q-trees Improved gradient fills three dimesnional objects in central projection PSTricks package for the japanese abacus Draw structural schemes in civil engineering analysis PSTricks package for manipulating text PSTricks package for trees draw easily diagrams with UML notation Author’s Home Three dimensional views 5 2.2 Syntaxe d’un commande PSTricks Les commandes se présentent ainsi \fonction [paramètre(s) optionnel(s)] (coordonnées){paramètre(s) obligatoire(s) } cercle [trait rouge](position du centre x=2 y=2 ){ rayon =1 cm } \pscircle [linecolor=red]( 2,2 ){ 1cm } : 6 2.3 Objets de base Voici un échantillonnage des possibilités 10 b b 9b b 8 b b 7 b b 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 \begin{pspicture}*(-1,-1)(11 ,11)\psgrid(0,0)(0,0)(10,10) \psset{linewidth=2pt} \psline(0,0)(1,1)(2,1)(3,2) \pspolygon(5,1)(6,0)(7,2)(6,2) \psframe(0,3)(3,4) \pscircle(5,3){1} \pswedge(7,4){2}{-30}{60} \psellipse(2,6)(1,.5) \psarc[showpoints=true](4,6){1.5}{-45}{45} \psbezier(9,9)(6,7)(10,6)(8,9) \pscurve[showpoints=true](1,10)(0,9)(1,8)(2,7) \psccurve[showpoints=true](5,10)(4,9)(5,8)(6,7) \psdiamond(8,1)(1,1) \pstriangle(6,7)(1,1) \psparabola(3.5,10)(3,8) \end{pspicture} 7 Commande avec astérisque 10 9 b b b b 8 b b 7 b b 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 8 9 10 \begin{pspicture}*(-1,-1)(11 ,11)\psgrid(0,0)(0,0)(10,10) \psset{linewidth=2pt} \psline*(0,0)(1,1)(2,1)(3,2) \pspolygon*(5,1)(6,0)(7,2)(6,2) \psframe*(0,3)(3,4) \pscircle*(5,3){1} \pswedge*(7,4){2}{-30}{60} \psellipse*(2,6)(1,.5) \psarc*[showpoints=true](4,6){1.5}{-45}{45} \psbezier*(9,9)(6,7)(10,6)(8,9) \pscurve*[showpoints=true](1,10)(0,9)(1,8)(2,7) \psccurve*[showpoints=true](5,10)(4,9)(5,8)(6,7) \psdiamond*(8,1)(1,1) \pstriangle*(6,7)(1,1) \psparabola*(3.5,10)(3,8) \end{pspicture} 8 2.4 Paramétrage des objets b b b b b b b b \begin{pspicture}*(-1,-1)(11 ,11)%\psgrid(0,0)(0,0)(10,10) \psset{linewidth=2pt} \psline{[-o}(0,0)(1,1)(2,1)(3,2) \pspolygon[linestyle=solid,linewidth=3pt](5,1)(6,0)(7,2)(6,2) \psframe[linestyle=dashed,fillstyle=solid,fillcolor=blue](0,3)(3,4) \pscircle[linestyle=dotted,fillstyle=vlines](5,3){1} \pswedge[linecolor=red](7,4){2}{-30}{60} \psellipse[linecolor=blue](2,6)(1,.5) \psarc[showpoints=true](4,6){1.5}{-45}{45} \psbezier[doubleline=true](9,9)(6,7)(10,6)(8,9) \pscurve[showpoints=true,linewidth=.3cm](1,10)(0,9)(1,8)(2,7) \psccurve[showpoints=true](5,10)(4,9)(5,8)(6,7) \psdiamond[fillstyle=hlines](8,1)(1,1) \pstriangle[fillstyle=crosshatch](7,6)(1,1) \psparabola[shadow=true,shadowcolor=red](3.5,10)(3,8) \end{pspicture} 9 2.5 Texte en boite psframebox pscirclebox psdblframebox psshadowbox pstribox psdiabox pstribox pst-fr3d Remarque : l’exemple avec pstribox illustre l’utilisation du module « pst-grad » . Ce module est inclus dans le module « pst-all » l’exemple avec psdiabox illustre l’utilisation du module « pst-slpe » , une amélioration du module « pst-grad » l’exemple avec pst-fr3d illustre l’utilisation du module « pst-fr3d » ,du texte sous forme de bouton. \psframebox{psframebox} \psdblframebox[linecolor=red]{psdblframebox} \psshadowbox{psshadowbox} \pstribox{pstribox} \pscirclebox[fillstyle=solid,fillcolor=black]{\white pscirclebox} \pstribox[fillstyle=gradient,gradangle=15,gradbegin=blue,gradend=red]{ \white pstribox} \psdiabox[fillstyle=slope,slopebegin=red,slopeend=green]{psdiabox} 10 2.6 Génération d’un dessin en WYSIWYG Un programme en java permet de générer automatiquement du code PSTricks : LaTeXDraw 11 3 Insertion d’un dessin PSTricks dans un document 3.1 Directement dans le texte Les commandes PSTricks peuvent être utilisé directement dans le texte . Dans ce cas , l’élément se positionne par rapport à la position actuelle Exemple avec la commande \psline[linecolor=red](0,0)(2,2) la ligne est tracé ici . Vous pouvez remarquer que le dessin se superpose au texte ! 12 3.2 Dans un environnement pspicture \begin{pspicture}(4,4) \psframe(4,4) \pscircle[linecolor=red](2,2){1cm} \end{pspicture} Une boite de 4cm x 4cm est positionnée à l’endroit de la commande(visualisée ici par un cadre). Il n’y a plus de superposition par rapport au texte ! le texte qui suit directement la figure se trouve ici ! 13 3.3 Dans un environnement figure Votre dessin est traitée comme une image : vous pouvez lui donner une légende, la référencer dans une liste d’images ... Figure 1 – légende la figure \begin{figure}[!h] \centering \begin{pspicture}(2,2) \pscircle[linecolor=red](1,1){1cm} \end{pspicture} \caption{légende la figure}% le texte de légende et donne un numéro à la figure \label{votre référence} % permet de faire référence à cette figure \end{figure} 14 3.4 En tant qu’image flottante \begin{figure}[h ou b ou t] \begin{pspicture}(2,2) \pscircle[linecolor=red](1,1){1cm} \end{pspicture} \end{figure} Le rond bleu a l’option b (botton) et le rond vert a l’option h (here) 15 3.5 Habillage du dessin par le texte Deux modules permettent de positionner automatiquement le dessin dans le texte : « wrapfig » et « picins » \begin{wrapfigure}{l}{5cm} \begin{pspicture}(4,4) \psgrid \pscircle[linecolor=blue](2,2){1cm} \end{pspicture} \end{wrapfig} 4 3 2 1 0 0 1 2 3 4 1° ligne du texte 2° ligne du texte 3° ligne du texte 4° ligne du texte 5° ligne du texte 6° ligne du texte 7° ligne du texte 8° ligne du texte 9° ligne du texte 10° ligne du texte 11° ligne du texte 12° ligne du texte 16 3.6 Sur deux colonnes Si vous ne voulez pas utiliser une mise en page automatique, vous pouvez la commande « minipage » qui permet séparer la largeur de la page en deux parties. 4 Cette partie fait 60% de la largeur de la ligne Cette partie fait 40% de la largeur de la ligne On peut mettre ici du texte, un autre dessin , une équation mathématique ... 3 2 1 0 0 1 2 3 4 \begin{minipage}[C]{.60\linewidth} Cette partie fait 60\% de la largeur de la ligne \begin{pspicture}(4,4) \psgrid \pscircle[linecolor=blue](2,2){1cm} \end{pspicture} \end{minipage}\hfill \begin{minipage}[C]{.40\linewidth} Cette partie fait 40\% de la largeur de la ligne \bigskip On peut mettre ici du texte, un autre dessin , une équation mathématique ... \end{minipage} 17 3.7 Problème de cadrage problème solution On observe un dépassement du cadre fixé avec un risque d’empiétement sur les éléments avoisinants. Vous avez dans ce cas un avertissement « bad box » 18 On peut limiter l’image au cadre désiré grâce à l’ajout d’un astérisque : \begin{pspicture}*(4,4) 3.8 Changement de taille On peut facilement changer la taille en changeant la valeur de « unit » grâce à la commande \psset{unit=dimension) – ci-dessous à gauche vous avez un dessin réalisé à la taille par défaut « unit »= 1cm – ci-dessous à droite vous avez le même dessin mais avec « unit » fixé à 2 cm 4 4 3 3 2 2 1 0 1 0 1 2 3 4 0 0 1 2 3 4 Attention si vous précisez la dimension d’une variable la commande psset n’aura pas d’influence sur elle ! \begin{pspicture}(4,4) \psgrid \psframe[linecolor=red,linewidth=3pt](1,1)(3,3) \pscircle[linecolor=red,linewidth=3pt](2,2){1cm} % le rayon du cercle est de 1 cm \end{pspicture} \end{minipage}\hfill \begin{minipage}[C]{.56\linewidth} \psset{unit=2cm} \begin{pspicture}(4,4) \psgrid \psframe[linecolor=red,linewidth=3pt](1,1)(3,3) \pscircle[linecolor=red,linewidth=3pt](2,2){1cm}% le rayon du cercle reste de 1 cm \end{pspicture} \end{minipage} 19 4 Positionnement des objets dans un dessin 4.1 Quadrillage de référence La fonction \psgrid permet de visualiser la position des objets 4 3 \begin{pspicture}(4,4) \psgrid \psframe[linecolor=red,linewidth =3pt](1,1)(3,3) 2 \end{pspicture} 1 0 0 20 1 2 3 4 4.2 Superposition d’objets Attention à l’ordre des commandes \psframe (0,0)(3,3) %blue \psframe (1,1)(4,4) %red \psframe (1,1)(4,4) %red \psframe (0,0)(3,3) %blue Commencez le dessin par les éléments de l’arrière plan et finissez par ceux du premier plan ! 21 4.3 Placement d’objets Voici les différentes possibilités de placement d’objet par rapport au point de référence grace à la commande \rput ici placement d’une boite de texte avec l’option choisi 2 1 bottom top right left br bl tr tl Base Br Bl 0 0 1 2 3 4 5 6 7 8 9 10 11 \begin{pspicture}(11,2) \rput[l](2,1){\psframebox{left}}\rput[r](2,1){\psframebox{right}} % \rput[t](4,1){\psframebox{top}} \rput[b](4,1){\psframebox{bottom}} % \rput[tl](6,1){\psframebox{tl}} \rput[tr](6,1){\psframebox{tr}} \rput[bl](6,1){\psframebox{bl}} \rput[br](6,1){\psframebox{br}} % \rput[B](8,1){\psframebox{Base}} % \rput[Bl](10,1){\psframebox{Bl}} \rput[Br](10,1){\psframebox{Br}} % \qdisk(2,1){3pt} \qdisk(4,1){3pt} \qdisk(6,1){3pt} \qdisk (8,1){3pt} \qdisk(10,1){3pt} \end{pspicture} 22 4.4 Placement étiquettes Voici les différentes possibilités de placement d’objet par rapport au point de référence grace à la commande \uput Elle est plutôt adaptée au placement d’étiquettes. 2 + 1 u l r d 1 2x A .K B 3 √ 2x ul ur dl dr + 0 2 -1 0 1 2 3 4 5 6 7 8 \begin{pspicture}(0,-1)(8,3)\psgrid[gridcolor=lightgray,subgridcolor= white] \qdisk(1,1){1pt} \uput[u](1,1){u}\uput[r](1,1){r}\uput[d](1,1){d}\uput[l](1,1){l} % \qdisk(3,1){1pt} \uput[ur](3,1){ur}\uput[dr](3,1){dr} \uput[dl](3,1){dl}\uput[ul](3,1){ul} % \qdisk(6,1){1pt} \psset{labelsep=1cm} % fixe la distance entre le point et son étiquette % On peut insérer d’autres éléments que du texte ! : \uput[ur]{-45}(6,1){$2x+1$}\uput[dr]{135}(6,1){\includegraphics[width=0.1 \textwidth]{logoiut.eps}} \uput[dl]{-135}(6,1){$\sqrt{2x+2}$}\uput[ul]{45}(6,1){\<lAbAs > } 23 4.5 Rotation d’objet Un objet peut être placé et pivoté par rapport au point de référence grace à la commande \rput 4 45 ° 3 0 1 ro 5° ro -4 ta à tio n n à tio 0 ta ta 45 ° ro 1 tio n à 2 2 3 4 5 6 7 8 9 10 11 \begin{pspicture}(11,4)\psgrid[gridcolor=lightgray,subgridcolor=white] \rput{45}(2,1){\psframebox{rotatioon à 45°}} \rput{-45}(6,1){\psframebox{rotatioon à -45°}} \rput[l]{45}(8,1){\psframebox{rotation à 45°}} %changement du point de référence \qdisk(2,1){3pt} \qdisk(6,1){3pt} \qdisk (8,1){3pt} \end{pspicture} 24 4.6 Placement d’objet avec des coordonnées polaires avec la commande \SpecialCoor, on peut travailler entre autres en coordonnées cartésienne : ( x, y) en coordonnées polaire : ( r ; Θ) 4 3 2 \SpecialCoor \rput(2,3){ \psline(0.6;30)(0,0)(0.6;75) \psarc(0,0){0.5}{30}{75} \rput[bl](0.6,52.5){45°}} 45° 1 0 0 25 1 2 3 4 5 Les noeuds et leurs connexions Un outils de PSTricks très pratique est la possibilité de positionner des noeuds dans le document et de les relier. Un exemple simple A B \rnode{A}{\psframebox{$A$}} % définition du \hspace{2cm} % espacement de 2 cm entre les \rnode{B}{\psframebox{$B$}} % définition du \ncline{<->}{A}{B} % connexion(fléchée) des 26 noeud A 2 noeuds noeud B 2 noeuds 5.1 Echantillonage des noeuds disponibles 10 9 rnode 8 7 ovalnode 6 trinode 5 4 3 circlenode 2 1 0 rnode + b Rnode -1 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 \psset{unit=.6cm} \begin{pspicture}(-1,-1)(12 ,10)\psgrid[gridcolor=lightgray,subgridcolor= white] \rput(1,1){\rnode{A}{rnode}} % noeud rectangulaire \rput(5,0) {\Rnode{B}{Rnode}} \pnode(7,1){C} % noeud sans dimension \cnode(1,5){1}{D} % noeud sous forme de cercle vide \cnode*(5,5){1}{E} % noeud sous forme de cercle plein \rput(9,3){\circlenode{F}{circlenode}} % le texte du noeud dans un cercle \rput(5,7){\ovalnode{G}{ovalnode}} % le texte du noeud dans un ovale \rput(5,9){\rnode{A}{\psframebox{rnode}}} % pour avoir le texte dans une boite il faut utiliser psframebox \rput(9,6){\trinode{I}{trinode}} \dotnode[dotstyle=*](8.5,0.5){J} \dotnode[dotstyle=+](9.5,0.5){K} \fnode(10.5,.5){L} % pour positionner les points de référence \qdisk(1,1){2pt} \qdisk(5,0){2pt} \qdisk(7,1){2pt} } \qdisk(5,5){2pt} \qdisk(9,3){2pt} \qdisk(5,7){2pt} \qdisk(5,9){2pt} \end{pspicture} 27 \qdisk(1,5){2pt 5.2 Echantillonage des connexions disponibles M N O P I J K L E F G H A B C D \psset{unit=1cm} \begin{pspicture}(11 ,9)%\psgrid \rput(1,1){\circlenode{A}{A}} \rput(3,1){\circlenode{B}{B}} \rput(5,1){\circlenode{C}{C}} \rput(7,1){\circlenode{D}{D}} \rput(1,3){\circlenode{E}{E}} \rput(3,3){\circlenode{F}{F}} \rput(5,3){\circlenode{G}{G}} \rput(7,3){\circlenode{H}{H}} \rput(1,5){\circlenode{I}{I}} \rput(3,5){\circlenode{J}{J}} \rput(5,5){\circlenode{K}{K}} \rput(7,5){\circlenode{L}{L}} \rput(1,7){\circlenode{M}{M}} \rput(3,7){\circlenode{N}{N}} \rput(5,7){\circlenode{O}{O}} \rput(7,7){\circlenode{P}{P}} \ncline{->}{A}{B} \nccurve{->}{B}{G} \ncarc{->}{E}{F} \ncarc{->}{G}{F} \ncbar[angle=30]{->}{D}{H} \ncdiag{->}{C}{L} \ncdiagg{->}{I}{F} \ncangle{->}{J}{N} \ncangles{->}{K}{O} \nccircle{->}{P}{1} \end{pspicture} 28 5.3 Une application personnelle Echanges thermiques entre deux parois séparées par un gaz non transparent. gaz paroi S1 paroi S2 ε2 σT24 α1 E1 E1 (1 − αg )J2 αg J2 εg σTg4 J2 (1 − α2 )E2 (1 − α1 )E1 J1 αg J1 ε1 σT14 (1 − αg )J1 E2 α2 E2 29 \pspicture*(0,1)(15,10) \psframe[linewidth=0pt,linestyle=dotted,fillstyle=solid,fillcolor=magenta ](0,1)(2,10) \psframe[linewidth=0pt,linestyle=dotted,fillstyle=solid,fillcolor=magenta ](13,1)(15,10) \rput*(1,9){paroi $S_1$ } \rput*(14,9){paroi $S_2$} \rput*(7.5,9){gaz} \psframe[linewidth=1pt,linestyle=dotted,fillstyle=solid,fillcolor=yellow] (6.5,1)(8.8,10) \rput[cl](1.25,8){\rnode{A}{\psframebox{$\alpha_1E_1$}}} \rput[bl](3,7){\rnode{B}{\psframebox[fillstyle=solid,fillcolor=cyan]{$E_1 $}}} \rput[bl](7,7){\rnode{D}{\psframebox{$\alpha_g J_2$}}} \rput[bl](9.5,7){\rnode{E}{\psframebox[fillstyle=solid,fillcolor=cyan]{$J 2$}}} \rput[cl](14,8){\rnode{F}{\psframebox{$\varepsilon_2 \sigma T^4_2$}}} \pnode(2,5){G} \pnode(13,5){I} \rput[bl](7,5){\rnode{H}{\psframebox{$\varepsilon_g \sigma T^4_g$}}} \rput[bl](5,3){\rnode{J}{\psframebox[fillstyle=solid,fillcolor=cyan]{$J_1 $}}} \rput[bl](7,3){\rnode{K}{\psframebox{$\alpha_g J_1$}}} \rput[bl](12,3){\rnode{M}{\psframebox[fillstyle=solid,fillcolor=cyan]{$E _2$}}} \rput[cl](14,2.5){\rnode{N}{\psframebox{$\alpha_2E_2$}}} \rput[cl](1.25,2.5){\rnode{O}{\psframebox{$\varepsilon_1 \sigma T^4_1$}}} \ncline[nodesep=3pt,linewidth=3pt,linecolor=blue]{->}{B}{A} \ncline[nodesep=3pt,linewidth=3pt,linecolor=blue]{->}{D}{B} \mput*{\psframebox{$(1-\alpha_g)J_2$}} \ncline[nodesep=3pt,linewidth=3pt,linecolor=blue]{->}{C}{E} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{->}{F}{E} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{->}{E}{D} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{-}{B}{G} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{->}{G}{J} \mput*{\psframebox{$(1-\alpha_1)E_1$}} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{->}{J}{K} \ncline[nodesep=3pt,linewidth=3pt,linecolor=blue]{->}{K}{M} \mput*{\psframebox{$(1-\alpha_g)J_1$}} \ncline[nodesep=3pt,linewidth=3pt,linecolor=blue]{->}{M}{N} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{->}{O}{J} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{-}{M}{I} \ncline[nodesep=3pt,linewidth=3pt,linecolor=red]{->}{I}{E} \mput*{\psframebox{$(1-\alpha_2)E_2$}} \ncdiagg[nodesep=3pt,linewidth=3pt,linecolor=blue,angleA=-180]{->}{H}{B} \ncdiagg[nodesep=3pt,linewidth=3pt,linecolor=blue]{->}{H}{M} \endpspicture 30 5.4 Utilisation pour commenter une image Le moteur de Stirling Le déplaceur d’air Le piston \begin{minipage}[C]{.36\linewidth} \rnode{deplaceur}{Le déplaceur d’air} \rnode{piston}{Le piston} \end{minipage}\hfill \begin{minipage}[C]{.56\linewidth} \begin{pspicture}(8,7) \rput{0}(4,3.5){\includegraphics[width=8cm]{stirling.eps}} \rput{0}(6,6){\psframebox{Le moteur de Stirling}} %\psgrid % pour le positionnement des objets \qdisk(2,2.5){3pt} \qdisk(2.5,4.5){3pt} \pnode(2,2.5){pist} \pnode(2.5,4.5){depl} \ncangles[angleB=180]{piston}{pist} \ncangles[angleB=180]{deplaceur}{depl} \end{pspicture} \end{minipage} 31 5.5 Utilisation de psfrag module à installer : « \psfrag » Il permet de modifier un dessin créé par un autre logiciel exemple : j’ai créé se dessin sous « Xfig » E S F A l’aide de la commande psfrag, j’ai remplacé les lettres E,S et F, créé des noeuds et fait des liaisons avec le texte placé en vis à vis. E(p) gain statique constante de temps K 1 + τp S(p) \begin{minipage}[C]{.46\linewidth} \rnode{G}{gain statique} \rnode{T}{constante de temps} \end{minipage}\hfill \begin{minipage}[C]{.46\linewidth} \begin{psfrags} \psfrag{F}[B c]{\large$\dfrac{\rnode{GS}{K}}{1+\rnode{CT}{\tau} p}$} \psfrag{E}{E(p)} \psfrag{S}{S(p)} \includegraphics[width=6cm]{s1.eps} \end{psfrags} \ncangles[angleB=0,angleA=90]{GS}{G} \ncangles[angleB=0,angleA=-90]{CT}{T} \end{minipage} 32 6 6.1 Personnalisation Créer ses objets Si un objet est souvent utilisés avec des paramètres non standard, il peut être intéressant de le déclarer comme nouveau objet. Deux avantages : – Cela simplifie l’écriture – Si on désire changer un des paramètres, tous les objets seront automatiquement mis à jour mon objet personnalisé %création de l’objet \newpsobject{myboite}{psframebox}{fillstyle=solid,fillcolor=yellow, linewidth=2pt,linecolor=red} %utilisation du nouveau objet \myboite{mon objet personnalisé} 33 6.2 Créer ses styles De même pour les paramètres des objets \newpsstyle{myfleche}{arrowsize=4pt 6,arrowlength=2,doubleline=true} \psline[arrows=->,style=myfleche](3,0) \pscurve[style=myfleche]{<<->}(0,0)(3,-1)(6,0) 34 6.3 Créer ses commandes Pour un dessin répétitif avec un ou plusieurs paramètres variables, il peut être intéressant de créer une commande. Voici un exemple de schéma bloc utilisé en cours de contrôle régulation. Attention la déclaration des nouvelles commandes se fait avant le début du document ! \newcommand{\FTBO}[2]{ \hspace{1cm} \rnode{Aaa}{\psframebox{#1}} \hspace {1cm} \rnode{Bbb}{\psframebox{#2}} \ncline{Aaa}{Bbb} \hspace{1cm} \vspace{1cm}} \newcommand{\FTBF}[2]{ \hspace{1cm} \cnode{.5cm}{Aaa} \hspace{1cm}\rnode {#1}{\psframebox{#2}} \ncline{Aaa}{#1} \ncangles[angleA=0,angleB=-90] {#1}{Aaa}\hspace{1cm} \vspace{1cm}} Utilisation des 2 commandes créées : La boucle ouverte : \FTBO{$\dfrac{5}{p(1+5p)}$} {$\dfrac{1}{(1+9p)(1+15p)}$} la fonction en boucle fermée \FTBF{A} {$\dfrac{5}{p(1+5p)(1+9p)(1+15p)}$} Ce qui donne : La boucle ouverte : 5 p(1 + 5p) 1 (1 + 9p)(1 + 15p) 5 p(1 + 5p)(1 + 9p)(1 + 15p) la fonction en boucle fermée 35 7 Répétition de commandes 7.1 Répétitions linéaires \multirput(0,0)(0.3,0){15}{+} +++++++++++++++ + + + + + + + + + + + + + + + \multirput{45}(0,0)(0.3,-0.3) {15}{+} 36 7.2 Répétitions d’un motif Le motif de base Le motif répété 5 fois : \multips(2,0){5}{ \begin{pspicture}(0,-.5)(2,.5) \psbezier[fillstyle=solid,fillcolor=red](0,0)(1,.5)(2,0) \psbezier[fillstyle=solid,fillcolor=red](0,0)(1,-.5)(2,0) \end{pspicture}} 37 7.3 Répétitions paramétrables La commande « multido » permet répéter une commande en incrémentant une variable Exemple : variation de l’angle de rotation d’un dessin \begin{pspicture}(-4,-4)(4,4) \multido{\i=0+30}{12}{% \rput{\i}{ \psbezier[fillstyle=solid,fillcolor=blue](0,0)(1,.5)(2,0) \psbezier[fillstyle=solid,fillcolor=blue](0,0)(1,-.5)(2,0)}} \multido{\i=15+30}{12}{% \rput{\i}{ \psbezier[fillstyle=solid,fillcolor=red](0,0)(1,.5)(2,0) \psbezier[fillstyle=solid,fillcolor=red](0,0)(1,-.5)(2,0)}} \end{pspicture} 38 Les commandes « multido » peuvent être imbriquées Exemple de changement de taille après l’exécution d’une rotation complète .5.5 \begin{pspicture}(-4,-4)(4,4) \multido{\na=2+-0.2,\nb=1+-0.1,\nc=.50+-.05,\nd=-.50+.05,\ia=0+7.5,\ib =15+7.5}{8}{% %taille décroissante \multido{\i=\ia+30}{12}{% \rput{\i}{ \psbezier[fillstyle=solid,fillcolor=blue](0,0)(\nb,\nc)(\na,0) \psbezier[fillstyle=solid,fillcolor=blue](0,0)(\nb,\nd)(\na,0)}} \multido{\i=\ib+30}{12}{% \rput{\i}{ \psbezier[fillstyle=solid,fillcolor=red](0,0)(\nb,\nc)(\na,0) \psbezier[fillstyle=solid,fillcolor=red](0,0)(\nb,\nd)(\na,0)}} } \end{pspicture} 39 8 Utilisation de modules spécialisés 8.1 Circuit électrique Utilisation du module « pst-circ » R E L C 40 % Node definitions \pnode(1,1){A} \pnode(1,7){B} \pnode(3,1){C} \pnode(3,7){D} % Dipole node connections \Ucc[tensionlabel=$E$](A)(B){} \resistor(B)(D){$R$} \coil(D)(C){$L$} \capacitor[parallel,parallelarm =2.5](D)(C){$C$} % Wire \wire(A)(C) 8.2 Oscilloscope Utilisation du module « pst-osci » timeDiv : 5ms/div Channel A : 1 V/div OffsetA 0 Channel B : 1 V/div OffsetB 0 XY OFF OffsetC 0 timeDiv : 5ms/div Channel A : 1 V/div OffsetA 0 Channel B : 1 V/div OffsetB 0 XY ON OffsetC 0 timeDiv : 5ms/div Channel A : 1 V/div OffsetA 0 Channel B : 1 V/div OffsetB 3 XY OFF OffsetC 0 % Different amplitude \psscalebox{0.5}{\Oscillo[amplitude1=3, amplitude2=1.5]} % Different period \hfill \psscalebox{0.5}{\Oscillo[Lissajous=true,amplitude1=3,amplitude2=1.5, period2=50]} % Different phase \hfill \psscalebox{0.5}{\Oscillo[amplitude1=3.5,phase1=90,period1= 2E30,offset 2=3,amplitude2=-3,damping1=0.02,period2= 2E31,damping2=0.02,phase2=90] } 41 8.3 Les arborescences Utilisation du module « \pst-tree » Ce module est installé automatiquement avec le module « \pst-all » . Tcircle Tr Toval Tdia TR Ttri b \pstree[radius=3pt]{\Tcircle{Tcircle}}{% \TC \Tr{Tr} \pstree{\Toval{Toval}}{% \TC* \Tdia{Tdia} \pstree{\TR{TR}}{% \Tc*{.5cm} \Tc{.5cm} \Tdot} \Ttri{Ttri} } \Tp \Tf* \Tf } 42 8.4 Les ressorts ! utilisation du module « \pscoil » Ce module est installé automatiquement avec le module « \pst-all » . \pscoil[coilarm=1cm,linewidth=1pt,coilwidth=.5cm,arrowsize=3pt 6] {|->}(4,0) % \hspace{5cm} \pszigzag[coilarm=1cm,linewidth=1pt,coilwidth=.5cm,arrowsize=3pt 6] {*->}(4,0) % Liaison de noeuds \pnode(0,0){A} \pnode(5,0){B} \pnode(10,0){C} \nccoil{o->}[coilarm=1cm,linewidth=1pt,coilwidth=.5cm,arrowsize=3pt 6]{A }{B} \nczigzag[coilarm=1cm,linewidth=1pt,coilwidth=.5cm,arrowsize=3pt 6]{*->}{ B}{C} 43 8.5 Manipulation de texte Le module « pst-text » (inclus dans le module PSTricks-all) permet de manipuler du texte Par exemple , écrire du texte suivant une courbe ie UT ique et Ene rgie I Gé n q et T h e r mi E n I UT G én Th e rm ie ue et E ne er rgie IU T Génie T h qu mi e \begin{pspicture}*(-4,-2.5)(4,2.5) \psset{linewidth=0.2pt} \pstextpath[l](0,-2ex){\psellipse(0,0)(3.5,2)}{\textit{IUT Génie Thermique et Energie IUT Génie Thermique et Energie IUT Génie Thermique et Energie } } \end{pspicture} 44 8.6 Le laboratoire de chimie Utilisation du module « pst-labo » cb bcbcbc bc cb bc cbbc bcbcbc cb bc cbbc bc bc bc bc bc bc bc \begin{pspicture} \pstChauffageBallon[glassType=erlen,tubeRecourbe,recuperationGaz, substance=\pstTournureCuivre] \end{pspicture} 45 8.7 PSTricks et l’optique 2 modules existent « pst-optexp » et « pst-optic » 8.7.1 Module pst-optexp Il permet de créer un schéma d’optique. Des problèmes de compatibilité de modules m’empêchent de compiler l’exemple ci-dessous copier le code ci-dessous \begin{pspicture}(-4,-1)(3,3) \psset{labeloffset=0.5} \pnode(-2,0){LaserOut} \pnode(0,0){Grid} \pnode(4;45){Out} \pnode(2.5;67.5){Mvar} \psline[linewidth=2\pslinewidth, linecolor=red!90!black](LaserOut)(Grid) (Out)\psline(Grid)(Mvar) \optbox[endbox,optboxwidth=2,labeloffset=0](Grid)(LaserOut){diodelaser} \optretplate[position=0.3,labeloffset=0.8](LaserOut)(Grid){$\dfrac{ \lambda}{4}$} \optgrid(LaserOut)(Grid)(Out){grid} \mirror[variable](Grid)(Mvar)(Grid){M$_\mathrm{var}$} \end{pspicture} 46 8.7.2 pst-optic B B′ A A′ O \begin{pspicture}(-5,-1.5)(7,4) \rput (1.5 ,1.5){ % \lens[ lensType=DVG,lensGlass=true,lensWidth=0.5,rayColor=red,focus =-4, AB=2, spotAi =270, spotBi =90]} \end{pspicture} 47 9 9.1 9.1.1 PSTricks et les graphes Avec le module de base "‘pstrick-all"’ D’après un fichier de données \begin{pspicture}(8,6) \psaxes[Dx=2]{->}(0,0)(0,-1)(6,6) \fileplot{mesdata.dat} \end{pspicture} 5 4 3 2 1 0 −1 2 4 Les données sont dans le fichier « mesdata.dat » . Il doit être dans le même répertoire que le fichier . Dans l’exemple ci contre, le fichiers « mesdata.dat » contient les données suivantes 0 ,1, 1, 2, 2 ,3 ,3, 2 ,4 ,5 48 9.1.2 D’aprés l’équation de la fonction 1 0 0 10 20 30 \psplot[linecolor=red,plotstyle=curve]{0}{30}{ 2.718 x neg 5 div exp neg 1 add } −x La fonction ici f (x) = 1 − e 5 doit être notée en notation polonaise inverse ! Remarque : les modules PSTricks-add et xkeyval permettent de de définir la fonction de façon plus familière ! 49 9.1.3 Equation paramétrique 1 −1 1 −1 \parametricplot[linecolor=red,plotstyle=curve,plotpoints=2000]{0}{1000}{t sin t 4 mul sin } – x(t) = sin 4t – y(t) = sin t 50 9.2 9.2.1 Avec PSTricks-add et xkeyval Les axes et quadrillages Exemple du semi-logarithmique 103 102 101 100 0 1 2 3 \psset{unit=4cm} \pspicture(0.15,0.15)(2.5,3) \psaxes[axesstyle=frame,logLines=y,xticksize=0 3,xsubticksize=1, ylogBase=10,tickcolor=red,subtickcolor=blue,tickwidth=1pt,% subticks=20,xsubticks=10](3,3) \endpspicture 51 9.2.2 Notation algébrique 2 1 0 2 4 6 −1 −2 \begin{pspicture}(-1,-3)(8,3) \psframe(-1,-3)(8,3) \psplot[algebraic,linecolor=red,plotpoints=100]{0}{6} { 2* sin(2*x) } \psaxes[Dx=2]{->}(0,0)(0,-2)(7,2.5) \end{pspicture} 52 9.2.3 Coordonnées polaires 15 10 5 −5 5 \begin{pspicture}(-3,-1)(3,5) \psset{unit=.4cm} \psplot[polarplot=true,linecolor=red,plotstyle=curve,plotpoints=2000] {0}{420}{ x sin x 20 div mul } \psaxes[Dx=5,Dy=5] {->}(0,0)(-9,-3)(10,17) \end{pspicture} 53 9.2.4 Riemann 2 1 0 2 4 −1 −2 \psset{xunit=2cm} \begin{pspicture}(-1,-3)(5,3) \psframe(-1,-3)(5,3) \psplot[algebraic,linecolor=red,plotpoints=100]{0}{4} { 2* sin(2*x) } \psStep[algebraic,linecolor=blue,StepType=Riemann](0,4){30} { 2* sin(2*x) } \psaxes[Dx=2]{->}(0,0)(0,-2)(4.5,2.5) \end{pspicture} 54 9.2.5 2 Tangente 1 0 2 4 −1 −2 \begin{pspicture}(0,-2)(8,2) \psplot[algebraic,linecolor=red,plotpoints=100]{0}{4} { 2* sin(2*x) } \psplotTangent[algebraic,linecolor=blue]{2.5}{1}{ 2* sin(2*x) } \psaxes[Dx=2]{->}(0,0)(0,-2)(5,2.5) \end{pspicture} 55 9.3 Le module pst-math Il permet des courbes avec les fonctions – COS , SIN ,TAN ,SEC , COSEC, COTAN ,ACOS , ASIN , ATAN , COSH ,SINH TANH, ACOSH ,ASINH , ATANH – GAUSS ,SINC ,GAMMA ,GAMMALN ,BESSEL 4 3 2 1 −5 −4 −3 −2 −1 −1 1 2 3 4 −2 −3 −4 −5 \begin{pspicture}*(-5,-5)(5,5) \psaxes{->}(0,0)(-5,-5)(5,5) \psplot[linecolor=blue]{-5}{5}{x COSH } \psplot[linecolor=red]{-5}{5}{x SINH} \psplot[linecolor=green]{-5}{5}{x TANH} \psplot[linestyle=dotted,linecolor=blue]{1}{5}{x ACOSH} \psplot[linestyle=dotted,linecolor=red]{-5}{5}{x ASINH} \psplot[linestyle=dotted,linecolor=green]{-.999}{.999}{x ATANH} \psplot[linestyle=dashed,linecolor=blue,plotpoints=1000]{-5}{5}{x EXP } \psplot[linestyle=dashed,linecolor=blue,plotpoints=1000]{-5}{5}{x 2 2 GAUSS } \psplot[linestyle=dashed,linecolor=red,plotpoints=1000]{-5}{5}{x 0 .5 GAUSS} \psplot[plotpoints=1000]{-20}{20}{x SINC} \end{pspicture} 56 9.4 Le module pst-func Installer le module « pst-func » dans le préambule Documentation : « pst-doc-func.pdf » Il permet de tracer : – les fonctions polynomiales – les fonctions de Fourier – les fonctions de Bessel – les courbes de Gauss – les fonctions sinus intégral, cosinus intégral – les lois binomiales – la fonction de Lamé – les tableaux de valeurs d’une fonction 57 Exemple : Fonction polynomiale 2 1 b −1 b b b b b 1 −1 −2 −3 \psset{yunit=1cm,xunit=3cm} \begin{pspicture}*(-2,-4)(2.5,4) % les coefficients sont indiqués dans l’ordre croissant des exposants. ici y = 1 -2x ... \psPolynomial[coeff= 1 -2 -3 +2,linecolor=magenta,markZeros=true]{-1}{2} %La dérivée de la courbe précédente : \psPolynomial[coeff= 1 -2 -3 +2,Derivation=1,linecolor=blue,markZeros= true,zeroLineTo=0]{-.5}{1.5} \psaxes[Dx=1]{->}(0,0)(-1,-3)(2,2.5) \end{pspicture} 58 9.5 Les graphes en 3D A l’aide des modules – « pst-3d » (inclus dans le module pst-all) – « pst-3dplot » Exemple Paraboloïde z 6.0 5.0 4.0 3.0 2.0 -1 1. -1 . 0 0 .0 1. 0 1.0 2. 0 x -1 . 0 2.0 y \begin{pspicture}(-.25\linewidth,-1)(.25\linewidth,7.5) \psset{unit=0.8cm} \pstParaboloid[showInside=false, SegmentColor={[cmyk]{0.8,0.1,.11,0}}] {4}{5}% \pstThreeDCoor[xMax=3,yMax=3, zMax=7.5,IIIDticks] \end{pspicture} 59 Exemple Courbe paramétrique x = r cos t y = r sin t t z= 600 z x y \begin{pspicture}(-3.25,-2.25)(3.25,5.25) \psset{unit=0.8cm} \pstThreeDCoor[zMax=5] \parametricplotThreeD[xPlotpoints=200,linecolor=blue,% linewidth=1.5pt,plotstyle=curve](0,2160){ 2.5 t cos mul 2.5 t sin mul t 600 div} \end{pspicture} 60 9.6 9.6.1 La 3D avec pst-solides3d Objets en 3D 61 9.6.2 Courbe en fer à cheval z 4 3 2 1 0 -1 -2 -4 -4 y x -3 -3 -2 -1 0 1 2 3 4 4 3 2 1 0 -1 -2 -3 -4 \psset{unit=0.75} \psset{lightsrc=30 30 25} \psset{SphericalCoor,viewpoint=50 40 30,Decran=50} \begin{pspicture}(-6,-8)(7,8) \psSurface[ngrid=.25 .25,incolor=yellow, linewidth=0.5\pslinewidth, axesboxed,algebraic,hue=0 1](-4,-4)(4,4){% ((y^2)-(x^2))/4 } \end{pspicture} 62 9.6.3 Fusion de 2 solides \begin{pspicture}(-.25\linewidth,-1)(.25\linewidth,7.5) \psset{solidmemory} %le premier solide nommé A1 : \psSolid[object=cylindrecreux,h=10,r=2,fillcolor=white,mode=4,name=A1, incolor=green!50](0,0,-3) %le deuxième solide nommé B1 : \psSolid[object=conecreux,h=15,r=2,RotY=-60,fillcolor=white,incolor=red !50,mode=5,name=B1](4,0,0)% %la fusion des 2 solides \psSolid[object=fusion,action=draw**,base=A1 B1,](0,0,0) \composeSolid \end{pspicture} 63 9.7 Les graphes avec géogebra Le logiciel libre geogebra permet – d’exporter des dessins au format eps qui peuvent être insérer dans la document – de générer du code PSTricks : exemple \documentclass[10pt]{article} \usepackage{\PSTricks,\PSTricks-add,pst-math,pst-xkey} \begin{document} \newrgbcolor{xdxdff}{0.49 0.49 1} \psset{xunit=1.0cm,yunit=1.0cm,algebraic=true,dotstyle=*,dotsize=3pt 0, linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25} \begin{pspicture*}(-4.32,-5.55)(11.07,6.82) \psaxes[xAxis=true,yAxis=true,Dx=2,Dy=2,ticksize=-2pt 0,subticks=2] {->}(0,0)(-4.32,-5.55)(11.07,6.82) \rput{0}(0,1){\psplot{-3.5}{3.5}{x^2/2/0.25}} \psplot{-4.32}{11.07}{(--16--4*x)/4} \rput[bl](-0.03,1.52){$c$} \psdots[linecolor=xdxdff](-4,0) \rput[bl](-3.91,0.14){\xdxdff{$A$}} \psdots[linecolor=xdxdff](0,4) \rput[bl](0.09,4.15){\xdxdff{$B$}} \rput[bl](-4.2,0.28){$a$} \end{pspicture*} \end{document} 64 10 PSTricks et la géométrie Utilisation du module « pst-eucl » 10.1 Les points 2 b D 1 rs 0 -1 B b E3 b b A b F3 b E2 -2 b b -2 E -1 1 b 0 C F1 1 F2 2 \pstGeonode{A} \pstGeonode(1,2){B} \pstGeonode[PtNameMath=false](2,1){C} \pstGeonode[PointSymbol=square,PosAngle=90](-1,1){D} \pstGeonode[ CurveType=polygon](-1,-2){E_1}(-2,-1){E_2}(-1,0){E_3} \pstGeonode[ CurveType=curve](1,-2){F_1}(2,-1){F_2}(1,0){F_3} \ncline{<-}{G}{D} 65 10.2 Les segments de droite 2 1 b B b D 0 -1 -2 C b b A -2 -1 0 1 2 \pstGeonode(-2,-2){A}(-1,1){B}(0,-1){C}(2,1){D} \pstSegmentMark{A}{B} \pstLineAB[linecolor=red,nodesepB=-1]{B}{C} \pstSegmentMark[linecolor=blue,SegmentSymbol=MarkCros]{C}{D} 66 10.3 Les triangles 5 B 4 b 3 α 2 b D 1 0 b G b -1 C -2 -3 -4 -5 b A -6 -6 -5 -4 -3 -2 -1 0 1 2 3 \pstTriangle(-4,-4){A}(0,4){B}(4,0){C} \pstMarkAngle[linecolor=green]{A}{B}{C}{$\alpha$} \pstMiddleAB{B}{C}{D} \pstCGravABC{B}{C}{A}{G} 67 4 5 5 B 4 b 3 2 1 N b 0 b -1 I b b O -2 b C M -3 -4 -5 b A -6 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 \pstTriangle(-4,-4){A}(0,4){B}(4,0){C} \pstCircleABC[linecolor=magenta]{B}{C}{A}{O} \pstMediatorAB[CodeFig=true,linecolor=red]{B}{A}{I}{M} \pstBissectBAC[linecolor=blue]{B}{C}{A}{N} 68 10.4 Les cercles 3 2 1 b A b B b D 0 -1 b C -2 \pstGeonode(-2,1){A}(-1,1){B}(0,-1){C}(2,1){D} \pstCircleOA{B}{C} \pstCircleAB[linecolor=red]{A}{B} \pstCircleOA[Radius=\pstDistAB{C}{D},linecolor=blue]{B}{} 69 10.5 Les transformations 3 2 A b G b 1 F b B H b 0 b b O -1 -2 b E b D b C -3 -4 \pstGeonode(-2,2){A}(1,2){B}(0,0){O} \pstSymO[CodeFig=true,linecolor=blue,CodeFigColor=blue]{O}{A,B}[C,D] \pstRotation[RotAngle=90,CodeFig=false,linecolor=red,CodeFigColor=red]{O }{A,B}[E,F] \pstHomO[linecolor=magenta,HomCoef=.66,CodeFigColor=magneta]{O}{A,B}[G,H] \pstLineAB[linewidth=2pt]{A}{B} \pstLineAB[linewidth=2pt]{C}{D} \pstLineAB[linewidth=2pt]{E}{F} \pstLineAB[linewidth=2pt]{G}{H} 70 10.6 Les intersections 4 b G 3 b b 2 b D b A E b 1 B I 0 b C -1 b F -2 b -3 H -4 -6 -5 -4 -3 -2 -1 0 1 2 3 4 \psset{unit=1.5cm} \begin{pspicture}*(-7,-5)(5,5) \psgrid[gridcolor=lightgray,subgridcolor=white](-6,-4)(5,5) \pstGeonode(-2,1){A}(1,3){B}(0,0){C}(-2,2){D} \pstInterLL[CodeFig=true,linecolor=blue,CodeFigColor=blue]{A}{B}{C}{D}{E} %intersection E de 2 droites \pstCircleOA[linecolor=red]{A}{B} \pstCircleOA[linecolor=red]{C}{D} \pstInterLC[CodeFig=true,linecolor=blue,CodeFigColor=blue]{C}{D}{A}{B}{F }{G} %intersections F G droite et cercle \pstInterCC{C}{D}{A}{B}{H}{I} % intersections H I de 2 cercles \pstLineAB[linewidth=2pt]{A}{B} \pstLineAB[linewidth=2pt]{C}{D} \pstLineAB[linewidth=.2pt]{G}{F} \pstLineAB[linewidth=.2pt]{H}{I} \end{pspicture} 71 Intersection avec une fonction 5 4 3 2 b b K D 1 0 b C -1 -2 b J -3 -4 -6 -5 -4 -3 -2 -1 0 1 2 3 4 \begin{pspicture}*(-7,-5)(5,5) \psgrid[gridcolor=lightgray,subgridcolor=white](-6,-4)(5,5) \pstGeonode(0,0){C}(-3,2){D} \pstCircleOA[linecolor=red]{C}{D} \pstLineAB[linecolor=red,nodesepA=-4]{C}{D} \def \F{x 2 exp neg 5 add } \psplot{-8}{3}{\F} \pstInterFL{\F}{C}{D}{1}{J} %intersection J proche de x=1 de F et la droite passant par C et D \pstInterFC{\F}{C}{D}{-1}{K} %intersection K proche de x=1 de F et du cercle \pstLineAB[linewidth=.2pt]{K}{J} % utilisation des points d’intersersion \end{pspicture} 72 11 11.1 Animation Animation d’objets PSTricks Utilisation du module « animate » \begin{animateinline}[ controls,loop,autoplay]{5}% \begin{pspicture}(6,6)%\psgrid \rput(3,3){\includegraphics[width=3cm]{logoiut.eps}} \pscircle[linecolor=blue,linewidth=3pt](3,3){2.5} \end{pspicture} \newframe% \begin{pspicture}(6,6)%\psgrid \rput(3,3){\includegraphics[width=3cm]{logoiut.eps}} \pscircle[linecolor=red,linewidth=3pt](3,3){2} \end{pspicture} \end{animateinline}% 73 11.2 Animation d’images 74 11.3 Animation : utilisation de whiledo %A mette dans le préambule !! %création d’une commande \newcommand{\mydessin}[1]{% \begin{pspicture}(-.25\linewidth,-1)(.25\linewidth,7.5) \psset{unit=.3cm} \psset{solidmemory} \psset{viewpoint=50 #1 20} \psSolid[object=cylindrecreux,h=10,r=2,fillcolor=white,mode=4,name=A1, action=none,incolor=green!50,SphericalCoor,viewpoint=50 30 20](0,0,-3) % \psSolid[object=conecreux,h=15,r=2,RotY=-60,fillcolor=white,incolor=red !50,action=none,mode=5,name=B1,SphericalCoor,viewpoint=50 30 20] (4,0,0)% \psSolid[object=fusion,action=draw**,base=A1 B1,SphericalCoor,](0,0,0) \composeSolid% \end{pspicture}} %===================================================== % A mettre où le dessin doit être affiché ! \newcounter{iter} % declare le compteur de boucle \FPset{nInit}{30}% valeur initiale \FPset{nIncr}{30}% valeur de l’incrementation \begin{animateinline}[ controls,loop,autoplay]{12} \setcounter{iter}{0}% mise à zero du compteur de diapo \FPset{i}{30}% \mydessin{\i} % traçage de la première diapo \whiledo{\theiter<11}{% soit 12 diapo ! \newframe% \stepcounter{iter}% incrémentation du compteur \FPeval{n}{nInit+nIncr*\theiter}%calcul de la nouvelle valeur de n \mydessin{\n}} % tracer du dessin avec la nouvelle valeur de n \end{animateinline} 75 12 12.1 Pour en savoir plus Sur votre ordinateur De nombreuses documentations au format pdf se trouve dans les répertoires – XXXX\doc\latex(XXXX : votre répertoire d’installation ) – XXXX\doc\géneric. Le fichier à consulter, voire à imprimer, est le fichier « pst-user.pdf » . C’est lui qui décrit toutes les commandes de base de PSTricks. 12.2 Sur le WEB – http://tug.org/pstricks/main.cgi – http://melusine.eu.org/syracuse/pstricks/ : un site à visiter ! – http://www.grappa.univ-lille3.fr/FAQ-LaTeX/ : une foire aux questions 76 Table des figures 1 légende la figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 14 Index commande circlenode, 27 cnode, 27 dotnode, 27 fileplot, 48 fnode, 27 multido, 38 multips, 37 multirput, 36 ncangle, 28 ncangles, 28 ncarc, 28 ncbar, 28 nccircle, 28 nccurve, 28 ncdiag, 28 ncdiagg, 28 ncline, 28 newcommand, 35 newpsobject, 33 newpsstyle, 34 ovalnode, 27 pnode, 27 psarc, 7 psbezier, 7 pscircle, 7 pscurve, 7 psdiamond, 7 psellipse, 7 psframe, 7 psframebox, 27 psgrid, 20 psline, 7 psparabola, 7 pspolygon, 7 psset, 19 pstriangle, 7 pswedge, 7 qdisk, 24 Rnode, 27 rnode, 27 rput, 24 specialcoor, 25 trinode, 27 uput, 23 psccurve, 7 pscirclebox, 10 psdblframebox, 10 psdiabox, 10 psframebox, 10 psshadowbox, 10 pstribox, 10 rput, 22 Module animate, 73 picins , 16 psfrag, 32 pst-3dplot, 59 pst-circ, 40 pst-coil, 43 pst-eucl, 65 pst-fr3d , 10 pst-func, 57 pst-grad, 10 pst-labo, 45 pst-math, 56 pst-optic, 47 pst-osci, 41 pst-slpe, 10 pst-text, 44 pst-tree, 42 wrapfig , 16 78 Table des matières 1 Introduction 1.1 Avantages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Inconvénients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Premiers pas avec PSTricks 2.1 Chargement de PSTricks . . . . . . . . 2.2 Syntaxe d’un commande PSTricks . . . 2.3 Objets de base . . . . . . . . . . . . . 2.4 Paramétrage des objets . . . . . . . . . 2.5 Texte en boite . . . . . . . . . . . . . . 2.6 Génération d’un dessin en WYSIWYG . . . . . . 3 Insertion d’un dessin PSTricks dans 3.1 Directement dans le texte . . . . . 3.2 Dans un environnement pspicture . 3.3 Dans un environnement figure . . . 3.4 En tant qu’image flottante . . . . . 3.5 Habillage du dessin par le texte . . 3.6 Sur deux colonnes . . . . . . . . . 3.7 Problème de cadrage . . . . . . . . 3.8 Changement de taille . . . . . . . . document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . un . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 3 . . . . . . 4 4 6 7 9 10 11 . . . . . . . . 12 12 13 14 15 16 17 18 19 4 Positionnement des objets dans un dessin 4.1 Quadrillage de référence . . . . . . . . . . . . . 4.2 Superposition d’objets . . . . . . . . . . . . . . 4.3 Placement d’objets . . . . . . . . . . . . . . . . 4.4 Placement étiquettes . . . . . . . . . . . . . . . 4.5 Rotation d’objet . . . . . . . . . . . . . . . . . 4.6 Placement d’objet avec des coordonnées polaires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 20 21 22 23 24 25 5 Les 5.1 5.2 5.3 5.4 5.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 27 28 29 31 32 6 Personnalisation 6.1 Créer ses objets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2 Créer ses styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.3 Créer ses commandes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 33 34 35 noeuds et leurs connexions Echantillonage des noeuds disponibles . . . Echantillonage des connexions disponibles Une application personnelle . . . . . . . . Utilisation pour commenter une image . . Utilisation de psfrag . . . . . . . . . . . . 79 . . . . . . . . . . . . . . . 7 Répétition de commandes 7.1 Répétitions linéaires . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.2 Répétitions d’un motif . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 Répétitions paramétrables . . . . . . . . . . . . . . . . . . . . . . . . . . 36 36 37 38 8 Utilisation de modules spécialisés 8.1 Circuit électrique . . . . . . . . . 8.2 Oscilloscope . . . . . . . . . . . . 8.3 Les arborescences . . . . . . . . . 8.4 Les ressorts ! . . . . . . . . . . . 8.5 Manipulation de texte . . . . . . 8.6 Le laboratoire de chimie . . . . . 8.7 PSTricks et l’optique . . . . . . . 8.7.1 Module pst-optexp . . . . 8.7.2 pst-optic . . . . . . . . . . . . . . . . . . 40 40 41 42 43 44 45 46 46 47 . . . . . . . . . . . . . . . . . . 48 48 48 49 50 51 51 52 53 54 55 56 57 59 61 61 62 63 64 . . . . . . 65 65 66 67 69 70 71 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 PSTricks et les graphes 9.1 Avec le module de base "‘pstrick-all"’ . 9.1.1 D’après un fichier de données . . 9.1.2 D’aprés l’équation de la fonction . 9.1.3 Equation paramétrique . . . . . . 9.2 Avec PSTricks-add et xkeyval . . . . . . 9.2.1 Les axes et quadrillages . . . . . 9.2.2 Notation algébrique . . . . . . . . 9.2.3 Coordonnées polaires . . . . . . . 9.2.4 Riemann . . . . . . . . . . . . . . 9.2.5 Tangente . . . . . . . . . . . . . . 9.3 Le module pst-math . . . . . . . . . . . 9.4 Le module pst-func . . . . . . . . . . . . 9.5 Les graphes en 3D . . . . . . . . . . . . 9.6 La 3D avec pst-solides3d . . . . . . . . . 9.6.1 Objets en 3D . . . . . . . . . . . 9.6.2 Courbe en fer à cheval . . . . . . 9.6.3 Fusion de 2 solides . . . . . . . . 9.7 Les graphes avec géogebra . . . . . . . . 10 PSTricks et la géométrie 10.1 Les points . . . . . . . 10.2 Les segments de droite 10.3 Les triangles . . . . . . 10.4 Les cercles . . . . . . . 10.5 Les transformations . . 10.6 Les intersections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Animation 11.1 Animation d’objets PSTricks . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Animation d’images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Animation : utilisation de whiledo . . . . . . . . . . . . . . . . . . . . . . 73 73 74 75 12 Pour en savoir plus 12.1 Sur votre ordinateur . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12.2 Sur le WEB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 76 76 81