# psfrag + pst_char = bug

Denis Girou Denis.Girou at idris.fr
Fri May 26 20:10:44 CEST 2000

-----------------------------------------------------------------------------
This is the PSTricks mailing list, devoted to discussions about computational
graphics in (La)TeX using the PSTricks package from Timothy van Zandt.
For help using this mailing list, see instructions at the end of message.
-----------------------------------------------------------------------------

The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "Mats.Bengtsson" == Mats Bengtsson <matsb at bowmore.e.kth.se> writes:

Mats.Bengtsson> When a figure comes after the use of
Mats.Bengtsson> the pstricks command \pscharpath,
Mats.Bengtsson> the replacements are not displayed in the
Mats.Bengtsson> PS-file even though the DVI file looks OK.

Mats.Bengtsson> The following example illustrates the problem.
Mats.Bengtsson> When the figure is moved before the use of
Mats.Bengtsson> \pscharpath, everything works fine.

Mats.Bengtsson> pst-char that I could find on CTAN.

Mats.Bengtsson> ...

Mats.Bengtsson> \documentclass[a4paper]{article}

Mats.Bengtsson> \usepackage{graphicx}
Mats.Bengtsson> \usepackage{pst-char}
Mats.Bengtsson> \usepackage{psfrag}
Mats.Bengtsson> \usepackage{times}

Mats.Bengtsson> \begin{document}

Mats.Bengtsson> \begin{pspicture}(5,5)
Mats.Bengtsson>         \rput(0.5,0.01){\pscharpath{ABCD}}
Mats.Bengtsson> \end{pspicture}

Mats.Bengtsson> \begin{center}
Mats.Bengtsson>   \psfrag{s}[r][r]{$s(t)$}
Mats.Bengtsson>   \psfrag{x}[l][l]{$x(t)=v s(t)$}
Mats.Bengtsson>   \includegraphics[width=\linewidth]{SIMO.eps}\\[5mm]
Mats.Bengtsson> \end{center}
Mats.Bengtsson> \end{document}

True. There is a clear incompatibility between the two packages.
Both must "play" at low level with some PostScript operators (here the problem
concern the "show" one, that both locally redefine for their own usage).
pst-char' start to keep the old definition of "show", redefine it,
print it argument, then restore the old definition. I verify that it work as
expected in basic cases, nevertheless, as you have found, there is something
compromised for psfrag' later, and it own local redefinition of "show" is no
more active after a \pscharpath call.

I have no clean solution, and the psfrag' PostScript code is really
difficult to understand. As pst-char' is a minor package, not often used,
I'm afraid that no real PostScript expert will investigate the problem,
and so that it will probably remain for ever...

Nevertheless, if you really need to use both packages, it seems possible
to find a workaround. The following one work in my tests, just forcing the
redefinition of the "show" operator for each figure, as the one of PSfragDict
is lost somewhere. But, of course, this is specially ugly (and I do not
garantee that it has no bad side effect)...

\documentclass[a4paper]{article}

\usepackage{graphicx}
\usepackage{pst-char}
\usepackage{psfrag}
\usepackage{times}

\begin{document}

\begin{pspicture}(5,5)
\rput(0.5,0){\pscharpath[linecolor=red]{\Huge ABCD}}
\end{pspicture}

\begin{center}
\psfrag{s}[r][r]{$s(t)$}
\psfrag{x}[l][l]{$x(t)=v s(t)$}
\includegraphics[width=\linewidth]{SIMO.eps}
\end{center}

\makeatletter

\def\pfg at hidestart{%
\def\pfg@{}\count@=\z@\loop\ifnum\count@<\pfg at scount
\toks@=\expandafter{\expandafter\pfg at align\the\count at .}%
\edef\pfg@{\pfg@\the\toks@]}%
\Gin at PS@raw{/PSfrag where{pop\pfg@\the\pfg at scount\space
\ifpfg at debug1\else0\fi\space\pfg at orient/Begin
% D.G. modification begin - May. 26, 2000
%                PSfrag}{userdict /PSfrag{pop}put}ifelse}}
PSfrag}{userdict /PSfrag{pop}put}ifelse
/show { /rs PSfrag } B}}
% D.G. modification end

\makeatother

\begin{center}
\psfrag{s}[r][r]{$s(t)$}
\psfrag{x}[l][l]{$x(t)=v s(t)$}
\includegraphics[width=\linewidth]{SIMO.eps}
\end{center}

\end{document}

Denis Girou
--
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------

-----------------------------------------------------------------------------