I need to know the height of a TikZ node and store it in a length so it can later be used by other commands and reference this exact dynamic length.
So here is an MWE that illustrates what I want to do, but of course this is not how \totalheightof
works, it measures the height of the text, but I want to get the height of the node:
\documentclass{article}
\newlength{\heightOfMyNode}
\usepackage{tikz,calc}
\begin{document}
\begin{tikzpicture}
\node(mynode)[text width=3cm]{This is a node that varies in height and I need to know the hieght and store it in a length};
\end{tikzpicture}
\setlength{\heightOfMyNode}{\totalheightof{node.height}}
And here I want to use the length for a \rule{\heightOfMyNode}{2pt}
\end{document}
Looking forward to your suggestions, especially direct TikZ/PGF solutions that I overlooked, maybe with \veclen
?
tcolorbox
(section 12.9) includes\tcbsetmacrotowidthofnode
andtcbsetmacroheightofnode
to store these values inside a macro, but I don't know how to make them to survive outside thetikzpicture
.