# How to simplify my code with looping macros?

\documentclass{article}
\usepackage{pstricks,multido}

\begin{document}
\begin{pspicture}

\pswedge(0,0){2}{0}{15}
\pswedge*(0,0){2}{15}{30}
\pswedge(0,0){2}{30}{45}
\pswedge*(0,0){2}{45}{60}

\pswedge(0,0){2}{60}{75}
\pswedge*(0,0){2}{75}{90}
\pswedge(0,0){2}{90}{105}
\pswedge*(0,0){2}{105}{120}

\pswedge(0,0){2}{120}{135}
\pswedge*(0,0){2}{135}{150}
\pswedge(0,0){2}{150}{165}
\pswedge*(0,0){2}{165}{180}

\pswedge(0,0){2}{180}{195}
\pswedge*(0,0){2}{195}{210}
\pswedge(0,0){2}{210}{225}
\pswedge*(0,0){2}{225}{240}

\pswedge(0,0){2}{240}{255}
\pswedge*(0,0){2}{255}{270}
\pswedge(0,0){2}{270}{285}
\pswedge*(0,0){2}{285}{300}

\pswedge(0,0){2}{300}{315}
\pswedge*(0,0){2}{315}{330}
\pswedge(0,0){2}{330}{345}
\pswedge*(0,0){2}{345}{360}

\end{pspicture}
\end{document}

• Welcome to TeX.SE! – Zarko Jan 10 '17 at 5:08

\foreach from pgffor package is also available by default in PSTricks. As a result, you don't need to use \multido.

\documentclass[pstricks,preview,margin=5mm]{standalone}

\begin{document}
\begin{pspicture}(-2,-2)(2,2)
\foreach \i [evaluate = \i as \j using \i+15] in {0,30,..., 330}{\pswedge*{2}{\i}{\j}}
\end{pspicture}
\end{document}


The output is exactly the same as other answers.

• there are so many solutions ! thank you very much. – dozer Jan 11 '17 at 7:13
\documentclass[pstricks,preview,margin=5mm]{standalone}
\usepackage{multido}

\def\obj#1{%
\begin{pspicture}(-2,-2)(2,2)
\multido{\i=#1+30}{12}{\rput{\i}(0,0){\pswedge*(0,0){2}{0}{15}}}
\end{pspicture}%
}

\begin{document}
\obj{0}\obj{15}%
\end{document}


Note: Starred \pswedge does not need linestyle=none,linewidth=0 to remove the outline because it has been done automatically.

• thanks a lot, very good, and I wonder how you created the gif picture? – dozer Jan 10 '17 at 7:03
• @dozer: For free, see How to convert pstricks animation to GIF file? – Werner Jan 10 '17 at 7:48
• more simple, could you add any notes about the syntax like obj#1, \obj{0}\obj{15}, thank you very much – dozer Jan 11 '17 at 1:28

\documentclass{article}

\usepackage{pstricks,multido}

\begin{document}

\begin{pspicture}
\multido{\i=0+15}{24}{%
\def\dowedge{\pswedge}%
\ifodd\i\def\dowedge{\pswedge*}\fi
\dowedge(0,0){2}{\i}{\number\numexpr\i+15}%
}
\end{pspicture}

\end{document}


Potentially one could also draw a filled, black circle and insert 12 white wedges.

As a secondary request, you can set the linestyle to none, which removes the outer circle as well as the "inner dot". Effectively, there is then no need for printing the white wedges then, making to code a little lighter:

\documentclass{article}

\usepackage{pstricks,multido}

\begin{document}

\begin{pspicture}
\multido{\i=0+30}{12}{%
\pswedge*(0,0){2}{\i}{\number\numexpr\i+15}%
}
\end{pspicture}

\end{document}

• very good idea, better than my primal idea – dozer Jan 11 '17 at 1:32

Define first a circle with 24 degrees. Makes things easier:

\documentclass{article}
\usepackage{pstricks,multido}
\begin{document}

\begin{pspicture}
\degrees[24]