I have a script that takes some input data and outputs tikz-code that creates a visual representation of this data in the form of a node graph. The ouput of the current script using example data looks as follow at the moment:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[every node/.style={{inner sep=0.7em}}]
\node at (6em, 0em) (L1N1) [anchor=north, text width=4em]{\begin{center}N1\end{center}};
\node at (0em, -9em) (L2N1) [anchor=north, text width=4em]{\begin{center}N1\end{center}};
\node at (6em, -9em) (L2N2) [anchor=north, text width=4em]{\begin{center}N2\end{center}};
\node at (12em, -9em) (L2N3) [anchor=north, text width=4em]{\begin{center}N3\\L1\\L2\\L3\\L4\\L5\\L6 \end{center}};
\node at (0em, -18em) (L3N1) [anchor=north, text width=4em]{\begin{center}N1\end{center}};
\node at (12em, -18em) (L3N2) [anchor=north, text width=4em]{\begin{center}N2\end{center}};
\node at (6em, -27em) (L4N1) [anchor=north, text width=4em]{\begin{center}N1\end{center}};
\path [-] (L1N1) edge (6em, -7.0em);
\path [-] (6em, -7.0em) edge (6em, -7.0em);
\path [->] (6em, -7.0em) edge (L2N2);
\path [-] (L2N1) edge (0em, -16.0em);
\path [-] (0em, -16.0em) edge (0em, -16.0em);
\path [-] (L2N2) edge (6em, -16.0em);
\path [-] (6em, -16.0em) edge (12em, -16.0em);
\path [-] (L2N3) edge (12em, -16.0em);
\path [-] (12em, -16.0em) edge (12em, -16.0em);
\path [->] (0em, -16.0em) edge (L3N1);
\path [->] (12em, -16.0em) edge (L3N2);
\path [->] (12em, -16.0em) edge (L3N2);
\path [-] (L3N1) edge (0em, -25.0em);
\path [-] (0em, -25.0em) edge (6em, -25.0em);
\path [-] (L3N2) edge (12em, -25.0em);
\path [-] (12em, -25.0em) edge (6em, -25.0em);
\path [->] (6em, -25.0em) edge (L4N1);
\path [->] (6em, -25.0em) edge (L4N1);
\end{tikzpicture}
\end{document}
The generated graph looks like this:
The image illustrates the problem I have. As can be seen from the graph, I visualize it as several rows of Nodes with connections between nodes in different rows. Currently my node positions are computed entirely in the script but I do think that I need to go away from this, because I have a problem with not knowing the size of the nodes and the rightmost node in the second row is far too tall for the coordinates given, making the result a mess.
Is it possible to compute the Y-coordinate of each row automatically in tikz (as an offset from the bottom of the previous row)? I do believe I can use the "calc" tikzlibrary to get the bottom-most Y-coordinate of a given node but I have not been able to find a way to get the bottom-most Y-coordinate of several Nodes. Is there a way to do that or is there another approach I should take to solve this problem?
Here is a rough sketch on how I would like the end result to look, with the third line being offset based on the lower most point of the nodes of the second line:
I cannot generate the final representation of the graph externally, as I will need to put page-references both from and to the contents of some of the nodes.
Thank you for any help!
south
and not to thenorth
as you do to get the result you want. But this then changes the graph. So it's difficult to answer you without knowing how this code is created and what are the possibilities of your script. – AndréC Jun 28 '20 at 14:58