pgf
pgf copied to clipboard
document 'nested nodes'
Version
3.1.9a
Details
I think it should be documented in the manual that the concept of 'nested nodes' doesn't work well in general, and that almost always there are other solutions without nesting.
However, there exist situations where you have to use nested nodes. An example is center-aligning two rows of nodes: you have to know the width of the rows first to do that properly. AFAICS, the only 'official' way to have nodes within nodes is to use matrices. IMHO, something like the following MWE should be added to the manual – it took me hours to find out how to do it properly...
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{positioning}
\begin{document}
% Align two rows of nodes horizontally.
\begin{tikzpicture}[node distance=3mm]
\node[matrix] (x) {
\node (a) {short};
\node [right=of a]{looooong}; \\
};
\node[matrix] [above=of x] {
\node (b) {looooooongeeeeeeeeeer};
\node [right=of b] {short}; \\
};
\end{tikzpicture}
\end{document}
