First: This is a crosspost from {TeX} SE but the post there seems to be `dead', so I try here.
Consider the following code:
Code: Select all
\documentclass{article}
\usepackage{auto-pst-pdf,pstricks-add}
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN
\calc
\fp_eval:n
\ExplSyntaxOff
% Parameters
\def\radius{1.5 }
\def\doublelayers{2}
\def\columns{2}
\begin{document}
\begin{figure}[htbp]
\def\diameter{\calc{2*\radius}}
\def\distance{\calc{2*3^(1/2)*\radius}}
\def\width{\calc{(2*\columns+1)*\radius}}
\def\height{\calc{(2+3^(1/2)*(\doublelayers-1))*\radius}}
\centering
\begin{pspicture}(\width,\height)
\rput(\radius,\radius){
\multido{\rC=0+\diameter}{\columns}{
\multido{\rD=0+\distance}{\doublelayers}{
\psdot(\rC,\rD)
\pscircle(\rC,\rD){\radius}
}
}
}
\rput(!2 \radius mul 1 3 sqrt add \radius mul){
\multido{\rE=0+\diameter}{\columns}{
\multido{\rF=0+\distance}{\doublelayers}{
\psdot(\rE,\rF)
\pscircle(\rE,\rF){\radius}
}
}
}
\end{pspicture}
\end{figure}
\end{document}
Code: Select all
pdflatex -shell-escape <filename>.tex
\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 attached picture shows 2 double layers (where the curser in the circle i a screenshot mistake). With 3 single layers, the top row shouldn't be there.