[pstricks] Clash between memoir and pst-pdf?

Rolf Niepraschk Rolf.Niepraschk at gmx.de
Tue Feb 26 08:08:57 CET 2008


Alan Ristow schrieb:
> Hi all,
> 
> I have a document that uses memoir and pst-pdf for which I get an error 
> during the pdfLaTeX run when I use a psmatrix in a subfigure using 
> memoir's built-in commands for generating subfigures. The error only 
> arises when using pdfLaTeX -- regular LaTeX runs work fine both with and 
> without \usepackage{pst-pdf}. I seem to recall some issues with pst-pdf 
> and psmatrix in the past, but the information I've been able to dig up 
> on them has not been helpful.
> 
> The error, a minimal example, and my file list follow.
> 
> Thanks,
> 
> Alan
> 
> 
> ERROR: Misplaced alignment tab character &.
> 
> --- TeX said ---
> <argument> ... {psmatrix}[rowsep=2.2,colsep=2] A &
>                                                     B & C \\ & D & E 
> \end {ps...
> l.19 }
>        %
> 
> 
> EXAMPLE:
> 
> \documentclass{memoir}
> \usepackage{mempatch}%
> \usepackage{pstricks}%
> \usepackage{pst-node}%
> \usepackage{pst-pdf}%
> 
> \newsubfloat{figure}
> \listfiles
> 
> \begin{document}
> \begin{figure}
> \subbottom[Test.]{%
>    \begin{pspicture}(-0.5,-1.25)(2.5,3.75)%
>      \begin{psmatrix}[rowsep=2.2,colsep=2]
>        A & B & C \\
>        & D & E
>      \end{psmatrix}
>    \end{pspicture}
> }%
> \end{figure}
> \end{document}


...
This has nothing to do with memoir or subfigures. The following code 
give the same error:
%----------------------------------------------
\listfiles
\documentclass{article}
\usepackage{pst-pdf}
\usepackage{pst-node}

\newcommand\foo[1]{#1}

\begin{document}

\foo{%
    \begin{pspicture}(-0.5,-1.25)(2.5,3.75)%
      \begin{psmatrix}[rowsep=2.2,colsep=2]
        A & B & C \\
        & D & E
      \end{psmatrix}
    \end{pspicture}
}%

\end{document}
%----------------------------------------------

The reason is the need of changing the catcode of the & sign to be less 
  dangerous _before_ executing of \foo. It's similar to verbatim code as 
macro parameter.

A not very elegant solution:

\makeatletter
\newenvironment{harmlessAmpersand}{%
   \ifcase\ppf at TeX@mode\relax\or
     \@makeother\&
   \fi
}{%
}
\makeatother
...
\begin{harmlessAmpersand}
\foo{%
    \begin{pspicture}(-0.5,-1.25)(2.5,3.75)%
      \begin{psmatrix}[rowsep=2.2,colsep=2]
        A & B & C \\
        & D & E
      \end{psmatrix}
    \end{pspicture}
}%
\end{harmlessAmpersand}
...

...Rolf









More information about the PSTricks mailing list