Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use psfrag to replace tags in figures by LaTeX text and formulas. Recently I wanted to go one step further, lets say I have a figure that has two tags in it "a" and "b", I'd like to have a nice arrow going from "a" to "b", so my idea was to create nodes using psfrag

\psfrag{a}{\tikz[remember picture]\node (A){a};}
\psfrag{b}{\tikz[remember picture]\node (B){b};}

then import the figure and then add the arrow

\tikz \draw[->, remember picture] (A) -- (B) ;

needless to say (?) it doesn't work.....psfrag is doing some clever things in the background, but the nodes that have created are not available for me later...

Any ideas on how I could either make psfrag work or get similar functionality (within my framework more-or-less)?

share|improve this question
You need to use \tikz [overlay,remember picture] when drawing the path: Then the nodes are available to me. However, it seems like psfrag stacks all the nodes on top of each other to the left of the figure, and then shifts the output of the TikZ commands to their correct positions in the figure. TikZ doesn't know this, though, and does not update the coordinates. Try drawing a path with \tikz [overlay,remember picture] \draw (A.north west) -- (B.south east); to see what I mean. Looks like this won't work, unfortunately. –  Jake Jan 22 '11 at 20:06
@Jake: I did that, I just forgot that part when writing the question. –  Yossi Farjoun Jan 22 '11 at 20:45
@Jake: I'm confused about what aspects of this work and what don't. Even with \tikz [overlay,remember picture], the nodes are unknown and the attempt to draw the arrow fails. But I understand your comment to say that the arrow drawing succeeds. –  raxacoricofallapatorius Jun 12 '12 at 3:21

2 Answers 2

up vote 2 down vote accepted

A different approach could be to open the EPS file in inkscape and then save it as an EPS using the "EPS+LaTeX" option, which creates a tex file that contains all the text and a reference to the bare figure. The tex file is then called in the main document using \input

Here's an example using a file I just opened and saved in inkscape:



% Inkscape encloses all text in \smash{}, so we'll use that to automate creating nodes
% Not sure if that's safe (do other things routinely call \smash{}?)
\renewcommand{\smash}[1]{\oldsmash{\tikz[remember picture] \node (#1) {#1};}}

\tikzstyle{every picture} = [remember picture]


\tikz[overlay,->] \draw (a) -- (b);

share|improve this answer
Interesting...I'll try it out. –  Yossi Farjoun Jan 23 '11 at 18:06
Unless you absolutely need to have an EPS, you might want to consider using SVG. See this question: tex.stackexchange.com/questions/2099/… particularly the answer using Inkscape. You'll need the latest version (0.48) –  Martin Tapankov Jan 24 '11 at 10:16

PSTricks can do exactly what you want. Tobias Nähring describes this procedure in a presentation. I know you asked specifically for TikZ, but I figured that maybe a PSTricks solution is better than none.






Two points in an EPS file joined using PSTricks

share|improve this answer
it's interesting that pstricks can do it and I haven't been able to find a Tikz solution....I wonder if it's because of the enclosing pspicture.... –  Yossi Farjoun Jan 23 '11 at 18:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.