[Tex/LaTex] How to superimpose LaTeX on a picture

graphicsscalingsymbols

I know how to add a picture to my LaTeX file, e.g. \includegraphics[width=7cm]{curve.pdf}. What I'd now like to do is place some latex symbols onto the picture. Like a \gamma to name a curve. I do not want to do that in the graphics editing program e.g. because I might want to rename that curve later and don't want to repeat the editing process.

I know I can do a \put in a picture environment. But this environment forces me to specify its size at the beginning. That would be cumbersome since I'd have to go open the graphics file and do some calculations. Is there a way to get the dimensions (or aspect ratio) of a graphics file within LaTeX, so I might use it there? But even if I could do these calculations automatically, I still wouldn't like the redundancy of specifying the width for \includegraphics again, but I could live with that.

Also, is it possible to specify the size in cm to the picture environment? I just tried and got some errors.

So basically what I am looking for is a solution as simple as possible which:

a) lets me specify a width or a height and a file, and displays the image scaled while keeping its aspect ratio and then

b) lets me put LaTeX stuff inside the image in relative coordinates (percentages or 0…1), so I won't have to redo anything should I decide that the image needs to be a bit larger or smaller.

(b is kind of like setting \unitlength to the whole width=height for the 'picture' environment. But of course most images are not square and I also don't appreciate the redundancy (but could live with it).)

Best Answer

use the overpic package.

\documentclass{article}
\usepackage[percent]{overpic}

\begin{document}
\begin{overpic}[width=0.5\textwidth,grid,tics=10]{pictures/baum}
 \put (20,85) {\huge$\displaystyle\gamma$}
\end{overpic}
\end{document}

will give you

enter image description here

Remove the 'grid' option after you are done putting symbols in the picture. Overpic can basically be used as a replacement for \includegraphics. Also, recently a user found some minor bug where the figure turned out to be slightly shifted (probably due to a number rounding error). I never had (or noticed) this issue myself.