## Friday, November 30, 2012

### Deal with repetitive work in pstricks efficiently (2) --- multido

Last time we talked about doing repetitive work in postricks using command "\multirput", and this time "\multido" will be introduced. "\multido" is a much more general loop macro than "\multirput". You can use it like this "\multido {\loop_indication = start_value + increment} {loop_nums} {loop_content}", very simillar to loop in programming language. Some examples are shown below.

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

\begin{document}
\begin{pspicture}*(-0.5,0.5)(5.5,5.5)
\multido{\ix=0+1}{6}
{
\multido{\iy=0+1}{6}
{
\rput(\ix,\iy){(\ix,\iy)}
}
}
\end{pspicture}
\end{document}


 Fig.1 Deal with repetitive work in efficiently (2) --- multido

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

\begin{document}
\begin{pspicture}(2,2)
\pscircle*[linecolor=yellow](1,1){0.707}
\psset{linecolor=red}
\multido{\ix=0+15}{24}
{
\rput{\ix}(1,1){\psline(0.5,0.5)(1,1)}
}
\end{pspicture}
\end{document}

 Fig.2 Deal with repetitive work in efficiently (2) --- multido