3

enter image description here

Paragraph ended before \pst@@@picture was complete, what is wrong?

\documentclass[pstricks,border=12pt]{standalone}
\usepackage[nomessages]{fp}


\makeatletter
% Removing a trailing space in the original fp.sty.
% I think this problem should be fixed directly to the fp.sty
% to make this package more compact.
\def\FP@pow#1#2#3{%
    % #1 macro, which gets the result
    % #2 base
    % #3 exponent
    %
    \FP@beginmessage{POW}%
    %
    {\def\FP@beginmessage##1{}%
     \def\FP@endmessage##1{}%
     %
     \FPifzero{#2}%
        \FP@pow@zero{#3}%
     \else%
        \FPln\FP@tmpd{#2}%
        \FPmul\FP@tmpd\FP@tmpd{#3}%
        \FPexp\FP@tmp\FP@tmpd%
     \fi%
     %
     \global\let\FP@tmp\FP@tmp%
    }%
    %
    \FP@endmessage{}%
    %
    \let#1\FP@tmp%
}


\def\filter#1,#2#3\relax#4{%
    \if t#1%
        trunc(#4:#2)%
    \else   \if r#1%
        round(#4:#2)%
    \else   \if c#1%
        clip(#4)%
    \else
        \ERRORHERE
    \fi\fi\fi}

% \pstVerb concatenator
\def\LoadConstants{}

% Constant declarator invoked in the preamble
\newcommand\const[3][]{%
    \if\relax\detokenize{#1}\relax
        \edef\temporary{#3}%
    \else
        \edef\temporary{\filter#1,any\relax{#3}}%
    \fi
    \expandafter\FPeval\csname#2\expandafter\endcsname
        \expandafter{\expandafter{\temporary}}%
    \toks0=\expandafter{\LoadConstants\pstVerb}
    \edef\LoadConstants{\the\toks0 {/#2 \csname#2\endcsname\space def}}}


\def\pst@@picture@i[#1]#2(#3,#4){%
% BEGIN - redefine \const for invocation inside pspicture
    \renewcommand\const[3][]{%
    \if\relax\detokenize{##1}\relax
        \edef\temporary{##3}%
    \else
        \edef\temporary{\filter##1,any\relax{##3}}%
    \fi
    \expandafter\FPeval\csname##2\expandafter\endcsname
        \expandafter{\expandafter{\temporary}}%
        \pstVerb{/##2 \csname##2\endcsname\space def}\ignorespaces}%
% END - redefine \const for invocation inside pspicture
    \@ifnextchar(% ignore anything between [] and ()
% BEGIN - inject \LoadConstants into pspicture
    {\pst@@@picture[#1](#3,#4)\LoadConstants}%
    {\pst@@@picture[#1](0,0)(#3,#4)\LoadConstants}%
% END - inject \LoadConstants into pspicture    
}

\makeatother
\const{side}{2}
\begin{document}
\begin{pspicture}[showgrid](-\side,-\side)(\side,\side)

\end{pspicture}
\end{document}
3
\let\pst@@@\pst@@@picture
\def\pst@@@picture{%
  \renewcommand\const[3][]{%
    \if\relax\detokenize{##1}\relax \edef\temporary{##3}%
    \else                           \edef\temporary{\filter##1,any\relax{##3}}%
    \fi%
    \expandafter\FPeval\csname##2\expandafter\endcsname
        \expandafter{\expandafter{\temporary}}%
        \pstVerb{/##2 \csname##2\endcsname\space def}\ignorespaces}%
  \LoadConstants\pst@@@}%
  • I used this for my production. – kiss my armpit May 3 '13 at 21:37
5

When there's a following ( you're doing

\pst@@@picture[#1](#3,#4)\LoadConstants(

which is wrong. Change the final part into

% END - redefine \const for invocation inside pspicture
    \@ifnextchar(% ignore anything between [] and ()
% BEGIN - inject \LoadConstants into pspicture
    {\pst@bugs@@@picture{#1}{#3}{#4}}%
    {\pst@@@picture[#1](0,0)(#3,#4)\LoadConstants}%
% END - inject \LoadConstants into pspicture
}
\def\pst@bugs@@@picture#1#2#3(#4){\pst@@@picture[#1](#2,#3)(#4)\LoadConstants}

so that \pst@@@picture will see the right sequence of tokens.

  • Have you tested it yet? It produces new error messages. – kiss my armpit May 3 '13 at 10:17
  • @Bugbusters Sorry, I wrongly copied. It should be fixed now. – egreg May 3 '13 at 10:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.