0

I'm using the PSFrag package to embed LaTeX labels into my EPS figures (which I then import into my LaTeX document), which works fine except that my LaTeX labels aren't very visible, because the background on which they are superimposed is too crowded. My solution is to insert a rectfill command into the EPS document right before the dummy label which gets replaced by PSFrag. However, figuring out the proper dimension and position of this rectangle is a very time consuming process, in particular because I need to recompile everything to see the changes.

I don't know how exactly PSFrag does its magic, but is there a way to get the bounding box of the LaTeX label, so that I can automate this process? My attempt ('(g1)' is the dummy label to be replaced by PSFrag)

gsave
(g1)
true charpath
pathbbox
0.5 setgray
rectfill
grestore
(g1)
show

of combining pathbbox with charpath only gives me the bounding box of the dummy label, not the LaTeX label it gets replaced with.

  • 2
    easier would be to do the fill in tex, which has the sizes to hand \psfrag{a+b}{\colorbox[gray]{0.5}{$a+b$} or whatever – David Carlisle Sep 1 '17 at 13:57
  • Thanks, that's very useful to me. Placing the box afterwards is not the optimal solution however, because I do want certain parts of the graphic to be able to overlay the box. – BlenderBender Sep 1 '17 at 14:51
  • not sure what you mean by "afterwards": the psfrag replacement will happen at the point of the show in the eps file and any later postscript drawing will come on top of it, the psfrag labels are not done at the end of the eps rendering. – David Carlisle Sep 1 '17 at 15:30
  • I'm sorry, I was under the impression that PSFrag would draw the replacement labels afterwards (I really don't know how this package does what it does; I wish I would). Using \colorbox or \tcolorbox embedded into the replacement label then seems to be the perfect solution indeed. – BlenderBender Sep 1 '17 at 17:57
  • I just checked, and what you said appears to be incorrect: when I draw something (say an arrow) on top of the dummy label it appears at is should be in the eps figure itself, but in the final pdf document, after the dummy label is replaced by psfig, the label appears above the arrow, not below it. – BlenderBender Sep 1 '17 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.