[texhax] Using a variable to scale psfrags

Robin Fairbairns Robin.Fairbairns at cl.cam.ac.uk
Fri Jul 9 15:32:03 CEST 2004

> Hello,
> I am using the psfrag package to replace dummy text
> labels in some EPS figures. Getting all the labels to
> scale proportionally with the figure itself works fine
> with the \resizebox command, but I'm having trouble
> using a variable to scale the individual text labels
> with respect to the boxes in the figure. Here's what I
> have:
> \begin{figure}
>  \begin{psfrags}
>    \def\myscale{1.5}
>    \psfragscanon
>    \psfrag{tag1}[][][\myscale]{Label 1}
>    \psfrag{tag2}[][][1.75\myscale]{Label 2}
>    ...
> \resizebox{\textwidth}{!}{\includegraphics{foo.eps}}
>  \end{psfrags}
> \end{figure}
> The first two (optional) arguments to psfrag (empty in
> the example above) have to do with alignment; those
> work fine. The problem is with the third optional
> argument. TeX handles both psfrag lines above OK, but
> the presence of the second line results in a
> postscript file that crashes the ghostscript
> interpreter.

not surprising; you're giving it a scaling factor of 1.751.5, which is
at the very least confusing.

the false assumption is that tex (or something) is going to multiply
the two numbers together.  while there are packages that can do "real"
calculation, i would suggest they're more trouble than they would
save -- i think you have to bite the bullet and write separate macros
for different scale factors (or just do the whole lot by hand).

More information about the texhax mailing list