UK TeX FAQ -- question 95

### Labelling graphics

"Technical" graphics (such as graphs and diagrams) are often labelled with quite complex mathematical expressions: there are few (if any) drawing or graphing tools that can do such things.

This is where the psfrag package can help. Place an unique text in your graphic, using the normal text features of your tool, and you can ask psfrag to replace the text with arbitrary (La)TeX material. Psfrag's "operative" command is `\psfrag{PS text}{Repl text}`, which instructs the system to replace the original ("`PS`") text with TeX-typeset replacement text. Optional arguments permit adjustment of position, scale and rotation; full details may be found in pfgguide in the distribution. (Unfortunately, psfrag can't be used with PDFLaTeX, though one might hope that it would be susceptible to the same sort of treatment as is used in the pdftricks package.)

Another pleasing package 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.

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

`overpic.sty`
  macros/latex/contrib/supported/overpic.tar.gz
`psfrag.sty`
  macros/latex/contrib/supported/psfrag.tar.gz