[pstricks] multido controlled by postscript variables

Herbert Voss Herbert.Voss at FU-Berlin.DE
Thu Jan 25 18:48:12 CET 2018


Am 25.01.2018 um 15:21 schrieb Poul Riis:
> *Graphics with PSTricks <pstricks at tug.org <mailto:pstricks at tug.org>> 
> writes:*
> \def\nxmax{5}
> OK - thanks. To me it would be highly desirable if*all *parameters could 
> be transferable from postscript to pstricks commands.
> 
> In the project below I would like to replace \prim with \primminusone in 
> the red line. But when doing so I get an empty table. Why? And how can I 
> make it work?

\documentclass{article}
\usepackage{multido}
\usepackage[x11names]{xcolor}
\usepackage{pstricks-add}
\usepackage{amsmath}
\usepackage{xparse}

\ExplSyntaxOn
\DeclareExpandableDocumentCommand\calc{m}{\fp_to_decimal:n{#1}}
\ExplSyntaxOff

\newcommand\multitable[1]{\def\prim{#1}\edef\primminusone{\the\numexpr(#1 
- 1)}
\psset{unit=5mm}

\begin{pspicture}(-0.5,-#1)(#1,1)
   \rput(!#1 2 div 2){\huge\fcolorbox{Red1}{Gold1}{$a\cdot b \mod \prim$}}
   \psline[linecolor=blue](-0.75,-0.25)(\prim, -0.25)
   \psline[linecolor=red](0.85,0.75)(0.85,-12)
 
\psComment*[ref=r,linecolor=blue]{->}(-0.75,0.25)(0.75,0.25){\color{blue}$b$}%[\ncarc]
   \psComment*[linecolor=red]{->}(0,1)(0,-0.25){\color{red}$a$}
   \multido{\nh=1+1}{\primminusone}{%
   	\rput(!\nh\space 0.2 add 0.2){\textcolor{blue}{\nh}}
   	\rput(!0 \nh\space neg){\textcolor{red}{\nh}}
     \multido{\ng=1+1}{\primminusone}{%
       \rput(!\nh\space 0.2 add 1 neg \ng\space
       mul){\calc{(\ng*\nh)-trunc(\ng*\nh/\prim)*\prim}}}
   }
\end{pspicture}%
}
	
\begin{document}
\multitable{13}\\[1cm]
   $p=$\prim\\
   $p-1=$\primminusone
\end{document}


Herbert


More information about the PSTricks mailing list