Quantcast
Viewing all articles
Browse latest Browse all 28

How to use for (or foreach) instead of hardcoding

I am new to Tikz and I am trying to draw the followingImage may be NSFW.
Clik here to view.
enter image description here

So far I did this manually but I was wondering how a foreach-Loop would work.

\begin{document}    \begin{tikzpicture}[    %   \def\compOneOne{5}    %   \def\nodeName{C1}        node distance = 0pt,        square/.style = {draw=blue!60, fill=blue!5, very thick,             minimum height=3em, minimum width=3em, % <---            outer sep=0pt},        square2/.style = {draw=purple!60, fill=blue!5, very thick,                 minimum height=3em, minimum width=3em, % <---                outer sep=0pt},        ]        %Nodes        \node[square]   (a1) {};        \node[square, right=of a1] (a2) {};        \node[square, right=of a2] (a3) {};        \node[square, right=of a3] (a4) {};        \node[square, below=of a1] (b1) {};        \node[square, right=of b1] (b2) {};        \node[square, right=of b2] (b3) {};        \node[square2, below=of b1] (c1) {};        \node[square2, right=of c1] (c2) {};        \node[square2, right=of c2] (c3) {};        \node[square2, right=of c3] (c4) {};        \node[square2, below=of c1] (A1) {};        \node[square2, right=of A1] (A2) {};        \node[square2, right=of A2] (A3) {};        \node[square2, right=of A3] (A4) {};        \node[square2, right=of A4] (A5) {};        \node[square2, right=of A5] (A6) {};        \node[square2, right=of A6] (A7) {};        \node[square2, right=of A7] (A8) {};        \node[square2, below=of A1] (B1) {};        \node[square2, right=of B1] (B2) {};%       \node[square2, below=of B1] (C1) {};%       \foreach \number in {1,...,\compOneOne}{%           \node[square2, right=of \nodeName] (N-\nodeName) {};%           \nodeName = N-\nodeName;%           %       }    \end{tikzpicture}\end{document}

The stuff that's commented out shows my own attempts on it.Furthermore I was struggeling with naming conventions and how to rename my variable efficiently.It would be very nice of you to help me. Thanks in advance!


Viewing all articles
Browse latest Browse all 28

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>