3

Is there anyway to specify coordinates relative to the image size ? Consider for example the following code :

\begin{tikzpicture}
\node [inner sep=0pt,above right]
{\includegraphics[width=\textwidth]{somefig.png}};
\path (0,1) coordinate (top-left);
\path (1,1) coordinate (top-right);
\end{tikzpicture}

I want the coordinates (top-left) and (top-right) to correspond to the top left and top right corners of the image. What's the simplest way to do this ?

ticster
  • 319

1 Answers1

3

Give node a name with, say,

\node [inner sep=0pt,above right] (a) {\includegraphics[width=\textwidth]{somefig.png}};

Then you can refer to its corners with

\draw (1,1) -- (a.north east)

or similarly put coordinates

\coordinate (b) at (a.north west);
percusse
  • 157,807
  • Thanks, works like a charm. How can I generalize this though ? Say I want the coordinate that three quarters of the way west from the node, and 0.3 the way north from it. Any way to do this ? – ticster Sep 21 '14 at 16:05
  • 1
    @ticster Have a look at the link Torbjørn linked to. Or there is a more involved solution somewhere on TeXWelt.de but I don't know how to look for it. – percusse Sep 21 '14 at 16:08