段落在 \pst@@@picture 完成之前就结束了,这是哪里出了问题?

段落在 \pst@@@picture 完成之前就结束了,这是哪里出了问题?

在此处输入图片描述

段落在\pst@@@picture完成之前就结束了,有什么问题?

\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}

答案1

\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@@@}%

答案2

(你正在做

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

这是错误的。将最后部分改为

% 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}

这样\pst@@@picture我们就会看到正确的标记序列。

相关内容