Ceci est une ancienne révision du document !


Comment placer du texte LaTeX dans un graphique?

Les graphiques « techniques » (tels que les diagrammes) contiennent parfois des étiquettes de texte présentant des expressions mathématiques assez complexes : il existe peu d'outils de dessin ou de graphique (tel Metapost) qui peuvent faire de telles choses.

Cette question étudie donc les méthodes pour placer des étiquettes sur les graphiques produits par tous ces autres outils. Notez que le terme « étiquette » doit être interprété de manière large : de nombreuses techniques présentées ici peuvent être utilisées pour placer du texte mais aussi pour dessiner sur un graphique.

Avec l'extension “psfrag”

L'extension psfrag permet de gérer le cas où votre image est incluse en tant que fichier EPS. Ici, après avoir placé un texte unique dans votre graphique en utilisant les fonctionnalités de texte usuelles de vos outils, vous pouvez demander à psfrag de remplacer ce texte par du code \LaTeX avec la commande suivante :

\psfrag{texte original}{texte de remplacement}

Des arguments facultatifs permettent le réglage de la position, de l'échelle et de la rotation du texte de remplacement. Tous les détails peuvent être trouvés dans pfgguide dans la distribution.

Avec les extensions “pst-pdf” ou “pdfrack”

FIXME Traduire

Since psfrag works in terms of (encapsulated) PostScript files, it needs extra work for use with pdfLaTeX. Two techniques are available, using pst-pdf package in a mode designed to do this work; and using pdfrack.

The pst-pdf package can support this “extra work” usage. In fact, the pst-pdf support package auto-pst-pdf offers a configuration setting precisely for use with psfrag.

If you have the “right” environment (see below), you could try the pdfrack script bundle. The script aims to cut each figure out of your source, using it to produce a small LaTeX file with nothing but the figure inclusion commands. Each of these figure files is then processed to PostScript, compiled using the \psfrag commands, and the resulting output converted to PDF again.

Pdfrack is written to use the Unix Bourne shell (or equivalent); thus your environment needs to be a Unix-based system, or some equivalent such as cygwin under windows. (What is more, pdfrack's author is rather disparaging about his package; the present author has never tried it.)

Avec l'extension “psfragx”

The psfragx package goes one step further than psfrag: it provides a means whereby you can put the psfrag commands into the preamble of your EPS file itself. Psfrag has such a command itself, but deprecates it ; psfragx has cleaned up the facility, and provides a script laprint for use with Matlab to produce appropriately tagged output. (In principle, other graphics applications could provide a similar facility, but apparently none does.)

Emacs users may find the embedded editor iTe a useful tool for placing labels: it's a (La)TeX-oriented graphical editor written in Emacs Lisp. You create iteblock environments containing graphics and text, and may then invoke iTe to arrange the elements relative to one another.

Avec l'extension “overpic”

Another useful approach is overpic, which overlays a picture environment on a graphic included by use of \includegraphics. This treatment lends itself to ready placement of texts and the like on top of a graphic. The package can draw a grid for planning your “attack”; the distribution comes with simple examples.

Avec l'extension “lpic”

The lpic package is somewhat similar to overpic ; it defines an environment lpic (which places your graphic for you): within the environment you may use the command \lbl to position LaTeX material at appropriate places over the graphic.

Avec l'extension “pinlabel”

Pinlabel is another package whose author thought in the same sort of way as that of overpic; the documentation explains in detail how to plan your “labelling attack” — in this case by loading your figure into a viewer and taking measurements from it. (The package discusses direct use of ''ghostscript'' as well as customised viewers such as ''gsview'' or gv.)

Avec l'extension “pstricks”

Pstricks can of course do everything that overpic, lpic or pinlabel can, with all the flexibility of PostScript programming that it offers. This capability is exemplified by the pst-layout package, which seems to be a superset of both overpic and lpic.

Similarly, pgf/TikZ has all the power needed, but no explicit package has been released.

The pstricks web site has a page with several examples of labelling which will get you started; if pstricks is an option for you, this route is worth a try.

The confident user may, of course, do the whole job in a picture environment which itself includes the graphic. I would recommend overpic or the pstricks approach, but such things are plainly little more than a convenience over what is achievable with the do-it-yourself approach.


Source: Labelling graphics

3_composition/illustrations/annoter_un_graphique.1638517179.txt.gz · Dernière modification : 2021/12/03 07:39 de yannick.tanguy
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0