[pstricks] Macro problems...
Werner Grundlingh
wgrundlingh at gmail.com
Sat Dec 5 07:33:09 CET 2009
The following code produces the circulant C_8<1,2> (a graph on 8 nodes
v_0,...,v_7 and edges connecting v_i to v_{i+1}, v_{i+2}, v_{i-1} and
v_{i-2}, where the arithmetic is performed modulo 8) using some macros
from pstricks-add:
\documentclass{article}
\usepackage{pst-node,multido,pstricks}
\usepackage{pstricks-add}
\begin{document}
\begin{pspicture}(10,10)
\makeatletter
\SpecialCoor \degrees[8]%
\multido{\iN=0+1}{8}{%
\cnode*[linecolor=black,fillcolor=black](2;\iN){2pt}{v\iN}% Draw
the nodes/vertices
}
\multido{\iN=0+1}{8}{%
\psforeach{\nA}{1,2}{%
\pst at cntc=\iN
\advance\pst at cntc by \nA
\pst at mod{\pst at cntc}{8}\nextnode%
\psline[linewidth=0.5pt,linestyle=solid,nodesep=-0.5pt](2;\iN)(2;\nextnode)
}
}%
\makeatother
\end{pspicture}
\end{document}
However, putting the above in a macro (even without arguments) causes
LaTeX to complain. That is, the following is a problem:
\documentclass{article}
\usepackage{pst-node,multido,pstricks}
\usepackage{pstricks-add}
\providecommand{\circulant}{%
\makeatletter%
\SpecialCoor \degrees[8]%
\multido{\iN=0+1}{8}{%
\cnode*[linecolor=black,fillcolor=black](2;\iN){2pt}{v\iN}% Draw
the nodes/vertices
}
\multido{\iN=0+1}{8}{%
\psforeach{\nA}{1,2}{%
\pst at cntc=\iN
\advance\pst at cntc by \nA
\pst at mod{\pst at cntc}{8}\nextnode%
\psline[linewidth=0.5pt,linestyle=solid,nodesep=-0.5pt](2;\iN)(2;\nextnode)
}
}%
\makeatother%
}
\begin{document}
\begin{pspicture}(10,10)
\circulant
\end{pspicture}
\end{document}
Why is that? Better yet, how would I be able to make this work?
Werner
More information about the PSTricks
mailing list