# Conditions for PSTricks figure

I have tried to create a PSTricks figure based on only a few parameters but I have a problem.

Code

\documentclass{article}

\usepackage{expl3}

\ExplSyntaxOn
\cs_new_eq:NN
\calc
\fp_eval:n
\ExplSyntaxOff

% Parameters
\def\doublelayers{2}
\def\columns{2}

\begin{document}

\begin{figure}[htbp]
\centering
\begin{pspicture}(\width,\height)
\multido{\rC=0+\diameter}{\columns}{
\multido{\rD=0+\distance}{\doublelayers}{
\psdot(\rC,\rD)
}
}
}
\multido{\rE=0+\diameter}{\columns}{
\multido{\rF=0+\distance}{\doublelayers}{
\psdot(\rE,\rF)
}
}
}
\end{pspicture}
\end{figure}

\end{document}


The document should be compiled using

pdflatex -shell-escape <filename>.tex


Question

How do I change the code from using \doublelayers to using single layers? The point is that if there are 2n layers, there should be should be drawn n layers to the far-left and n layers indented by an amount of \radius; if there are 2n-1 layers, there should be should be drawn n layers to the left and n-1 layers indented.

Example: If I have three layers, the code should draw two rows of circles beginning at the left of the figure and one row of circles in between, indented.

The following picture shows 2 double layers. With 3 single layers, the top row shouldn't be there.

Update

I have crosspost this to the LaTeX Community since this post seems to be dead', so I try there.

-
I've posted one possible solution. I'm a bit unclear why this was difficult for you. I suspect that I am probably not understanding what you're really asking for. I think you'll get more bites if you post your own attempt (even if it doesn't work), at accomplishing what you want. –  A.Ellett Feb 26 '13 at 5:58

I'm really foggy on what you're asking for.

Is this what you're asking for?

If the above image is the case, there's a very easy solution:

\documentclass{article}

\usepackage{expl3}

\ExplSyntaxOn
\cs_new_eq:NN
\calc
\fp_eval:n
\ExplSyntaxOff

% Parameters
\def\doublelayers{3}
\def\columns{2}
\pagestyle{empty}
\begin{document}

\begin{figure}[htbp]
\centering
\begin{pspicture}(\width,\height)
\multido{\rC=0+\diameter}{\columns}{
\multido{\rD=0+\distance}{\doublelayers}{
\psdot(\rC,\rD)
}
}
}
%     \multido{\rE=0+\diameter}{\columns}{
%       \multido{\rF=0+\distance}{\doublelayers}{
%         \psdot(\rE,\rF)
%       }
%     }
%   }
\end{pspicture}
\end{figure}

\end{document}


Are you asking for something more or less dynamic, so that you can specify how ever many layers you want?

OK. I think I understand a bit better what you want. Here's a MWE. It could use some improving, but I'm tired right now. I'll come back to it tomorrow.

\documentclass{article}
\usepackage{xcolor}
\usepackage{expl3}

\ExplSyntaxOn
\cs_new_eq:NN
\calc
\fp_eval:n
\ExplSyntaxOff

% Parameters
\def\doublelayers{5}
\newcounter{bluedoublelayers}
\ifodd\doublelayers\relax%
\setcounter{bluedoublelayers}{\number\numexpr\doublelayers-1\relax}%
\else%
\setcounter{bluedoublelayers}{\doublelayers}%
\fi
\def\columns{2}
\pagestyle{empty}
\begin{document}

\begin{figure}[htbp]
\centering
\begin{pspicture}(\width,\height)
\multido{\rC=0+\diameter}{\columns}{
\multido{\rD=0+\distance}{\doublelayers}{
\psdot(\rC,\rD)
}
}
}
\psset{linecolor=blue}
\multido{\rE=0+\diameter}{\columns}{
\multido{\rF=0+\distance}{\thebluedoublelayers}{
\psdot(\rE,\rF)
}
}
}
\end{pspicture}
\end{figure}

\end{document}


When you set doublelayers to 2, the result is:

When you set doublelayers to 3, the result is:

-
This is exactly what I am asking for. :) I am not used to begin abel to attach pictures but I have done that now. –  Svend Tveskæg Feb 26 '13 at 6:06
This looks promising, @a.ellett! I would like to create single layers instead of doubles so that I can draw, say, three columns and three rows by setting \def\rows{3} (there \doublelayers is replaced by \rows) and \def\columns{3}`. –  Svend Tveskæg Feb 26 '13 at 14:20
Have you (or anyone else) come up with an idea of how to do what I would like to accomplish? –  Svend Tveskæg Mar 3 '13 at 8:19