I have several nodes and I need to find which one is the widest.
This example draws a vertical line in through the center of the widest node, but I know which node to choose.
\documentclass[12pt,a4paper]{article}\usepackage{tikz}\begin{document}\begin{tikzpicture} \foreach \name[count = \n] in {peter, wellingon, john, william}{ \node[draw, anchor = west] at (0, -\n) (name-\n) {\name}; } \draw let \p1 = (name-1.center) in (\x1, 0) -- (\x1, -5);\end{tikzpicture}\end{document}
Can I make this choice automatically? I could't find a way to get a coordinate and store it in a global macro for later use. The let
operator gives easy access to coordinates, but only inside a path, as far as I know.