[texhax] Using a variable to scale psfrags
Philip G. Ratcliffe
philipratcliffe at tiscali.it
Fri Jul 9 22:56:04 CEST 2004
> 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.
TeX does not do maths automatically! It's not even automatic that \myscale
should get expanded as it does in the first case (in other words, not all
commands expand their arguments as here). In the second case I imagine that
\psfrag passes something like 1.751.5 on to postscript! You'll have to use
something like \myscaleone and \myscaletwo and define their values before
calling \psfrag.
> I've tried \newcommand, \newlength, \newcounter, and
> \def -- but for various reasons, none of those work.
> I'd like to be able to only adjust the value of
> \myscale once at the top of each figure environment,
> instead of having to manually tweak all the \psfrag
> calls (some of my figures have ten or more).
There is indeed a package for doing floating arithmetic but I can't remember
it's name right now.
Cordialmente, Philip G. Ratcliffe
More information about the texhax
mailing list