# What would be the best way to draw this image using latex?

I have an assignment which involves drawing the layout of some wiring. I have been using a different program, but the rest of my work is in LaTeX and so I would like to learn how use LaTeX to create the image as well.

My image is here:

Essentially the little black squares need to be able to be connected to each other vertically across the gap. I have been using circuitikz to try to complete my task, but I haven't yet worked out how to create something that looks similar enough that someone would understand what it represented.

I am looking to create the image above, but without the fill or the grid lines, so it would be rows of little boxes with circles inside that could be connected by lines.

If anyone has any suggestions to which packages (if not circuitikz) or something that I could be doing in circuitikz then that would greatly be appreciated.

Cheers

• How elaborate will the image get? It doesn't seem like it would necessarily require the power of tikz. – Werner May 22 '14 at 4:08
• The most elaborate it could get is by having each point in the top row be connected to a different point in the bottom row so that they would be crossing over. – John W May 22 '14 at 4:18
• Do you want to use the diagram for etching PCB? Standard dimension must be well considered. – kiss my armpit May 22 '14 at 5:12

If you prefer to use TikZ, there is a solution, which reproduces the figure you pasted:

\def\mydot(#1,#2){
\filldraw[fill=red!80!black, draw=black, thick] (#1,#2) circle(0.4);
\fill[red!50!white] (#1,#2) circle(0.1);
}

\begin{tikzpicture}[scale=0.2]
% Background grid
\draw[cyan!40] (0,0) grid (74, 20);

% single dot
\mydot(5,16);

% Top row
\xdef\x{6}
\foreach \width in {4,6,8,8,5,8,8,8} { % the list is the width of each group
\foreach \i in {1,...,\width} {
\mydot(\x+\i, 17); \mydot(\x+\i, 16);
}
\pgfmathsetmacro{\x}{\x+\width+1}\xdef\x{\x}
}

% Bottom row
\xdef\x{6}
\foreach \width in {8,13,10,8,5,4,4} {
\foreach \i in {1,...,\width} {
\mydot(\x+\i, 4);
}
\pgfmathsetmacro{\x}{\x+\width+1}\xdef\x{\x}
}
\end{tikzpicture}


You can redefine \mydot macro to suit your needs (which I didn't fully understand). For example, this is what I think you described:

\def\mydot(#1,#2){
\draw[draw=black, thick] (#1-0.4,#2-0.4) rectangle +(0.8,0.8);
\draw[thin] (#1,#2) circle(0.2);
}


which produces (I commented out the \draw .. grid this time):

• Cheers, this is exactly what I was imagining! – John W May 22 '14 at 9:17

Run with xelatex (needs some time) or with latex->dvips->ps2pdf. ~ is one node, defined by row,col

\documentclass{article}
\usepackage{pst-node}
\begin{document}

\begingroup
\def~{ \pscircle[fillstyle=solid,fillcolor=red](0,0){2mm} & }
\begin{psmatrix}[emnode=p,colsep=4mm,rowsep=-1pt]
&&~~~~&~~~~~~&~~~~~~~~&~~~~~~~~\\ % 1
~&~~~~&~~~~~~&~~~~~~~~&~~~~~~~~\\ % 2
\\ \\ \\ % 3 4 5
\\ \\ \\ % 6 7 8
\\ \\ \\ % 9 10 11
&&~~~~~~~~&~~~~~~~~~~~~&~~~~~~~~~~\\ %12
\end{psmatrix}
\ncline[nodesep=2mm]{2,4}{12,16}
\nccurve[nodesep=2mm,angleA=30,angleB=45,ncurv=1.2]{->}{1,16}{12,33}
\endgroup
\end{document}


This is another TiKZ solution which uses matrix nodes. Redefine point style to change connectors appearance.

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{matrix,positioning}
\tikzset{
point/.style={circle,minimum size=2mm,fill=red, draw=red!30!black},
block/.style={matrix of nodes, nodes in empty cells, nodes={point, anchor=center}},
}

\begin{document}
\begin{tikzpicture}
\node[point] (A) {};
\matrix[block, right=3mm of A, matrix anchor=B-2-1.center] (B) {&&&\\&&&\\};
\matrix[block, right=3mm of B] (C) {&&&&&\\&&&&&\\};
\matrix[block, right=3mm of C] (D) {&&&&&&&\\&&&&&&&\\};
\matrix[block, right=3mm of D] (E) {&&&&&&&\\&&&&&&&\\};
\matrix[block, below=1cm of B-2-1, matrix anchor=F-1-1.center] (F) {&&&&&&&\\};
\matrix[block, right=3mm of F] (G) {&&&&&&&&&&&\\};
\matrix[block, right=3mm of G] (H) {&&&&&&&&&\\};

\draw[thick] (B-2-3.center) -- (G-1-5.center);
\draw[thick] (C-1-5.center) -- (F-1-2.center);
\end{tikzpicture}
\end{document}