1

I am trying to create a diagram to explain a mathematical structure which can be summarized as a binary lattice embedded in a net.

Essentially the net has a set of nodes on the top and a set of nodes on the bottom that need to be labeled.

Each point at the top has 2 outgoing edges that connect to 2 nodes below it, which themselves divide into 2 edges. This is almost like a binary tree except that nodes that are beside each other get merged into one.

Multiple of these structures are added partially overlapping, which creates something that kinda looks like this:

enter image description here

I am trying to create a labeled diagram with colored edges kinda like in the awful drawing using latex, but I am not even sure which package to use.

  • 1
    If you can make the prescriptions more precise, you may be looking for the lindenmayersystems library that ships with TikZ. – user194703 Dec 16 '19 at 2:09
  • 1
    This does a net of the type you describe: \documentclass[tikz,border=3mm]{standalone} \begin{document} \begin{tikzpicture} \foreach \Y [evaluate=\Y as \Xmax using {int(abs(\Y)+2)}] in {0,...,-4} {\foreach \X in {-\Xmax,...,\Xmax} {\draw (\X,\Y) -- ++ (-135:{sqrt(2)}) (\X,\Y) -- ++ (-45:{sqrt(2)});} \draw ({-\Xmax-1/2},{\Y-1/2})-- ++ (-45:{1/sqrt(2)}) ({\Xmax+1/2},{\Y-1/2})-- ++ (-135:{1/sqrt(2)}); } \end{tikzpicture} \end{document}. Maybe this can be a basis for a clearer question. – user194703 Dec 16 '19 at 4:34
  • That's actually really close to what I need, the only 2 things I would be missing are labels and being able to color edges – Makogan Dec 16 '19 at 6:19
  • 1
    It is easy to add labels if one knows what the contents of these labels are. Do you have any suggestions. Likewise, coloring is straightforward if it is known what the rules for coloring are. – user194703 Dec 16 '19 at 6:22
4

Here is something to give you a start.

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
 \clip ({-4*sqrt(2)},0) rectangle ({4*sqrt(2)},{2*sqrt(2)});
 \draw[rotate=45,semithick] (-4,-4) grid[step=5mm] (4,4);
 \draw[yshift={4*sqrt(2)*1cm},rotate=45,red,thick] (-4,-4) grid[step=5mm] (4,4);
\end{scope} 
\path foreach \X [count=\Y] in {A,B,...,I} 
 {({(-5+\Y)*sqrt(1/2)},{2*sqrt(2)}) node[above]{\X}}
 foreach \X [count=\Y] in {A,B,...,Q} 
 {({(-9+\Y)*sqrt(1/2)},{0}) node[below]{\X}};
\end{tikzpicture}
\end{document}

enter image description here

If it is clear what the precise requirements I will be happy to make it more versatile.

Here is a way to label the edges. The position 4.5/8 is explained by the path from A on the top to I on the bottom having 8 steps, and the label is on the stretch between the 4th and 5th node.

\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
 \clip ({-4*sqrt(2)},0) rectangle ({4*sqrt(2)},{2*sqrt(2)});
 \draw[rotate=45,semithick] (-4,-4) grid[step=5mm] (4,4);
 \draw[yshift={4*sqrt(2)*1cm},rotate=45,red,thick] (-4,-4) grid[step=5mm] (4,4);
\end{scope} 
\path foreach \X [count=\Y] in {A,B,...,I} 
 {({(-5+\Y)*sqrt(1/2)},{2*sqrt(2)}) coordinate (\X-top) node[above]{\X}}
 foreach \X [count=\Y] in {A,B,...,Q} 
 {({(-9+\Y)*sqrt(1/2)},{0}) coordinate (\X-bot)  node[below]{\X}};
 \path[red] (A-top) -- (I-bot) node[midway,pos=4.5/8,sloped,above] {$x$};
\end{tikzpicture}
\end{document}

enter image description here

  • This is awesome, thank you. Last question, is there a way to label some of the edges as well? like, say on of the red edges in the middle? – Makogan Dec 16 '19 at 16:39
  • 1
    @Makogan Sure, I quickly added something. Will be offline now for a while. – user194703 Dec 16 '19 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.