[Tex/LaTex] Is it possible to use the width of one TikZ node to calculate the width of another

calculationstikz-pgf

Question

Is it possible to store the variable width of a node and use that width to calculate the text width of another node in TikZ?

Example

I have a list of similar nodes side-by-side (inline, not overlaid). Let's call the left column of nodes "A" and the right column of nodes "B". Column A nodes contain a number (counter variable, which means the node gets wider at each digit carry-over). Column B nodes should have some text width minus the text width of the corresponding node in column A.

  • get width of node A = \fontsize{50}{60}\selectfont\countervalue{}

  • text width of node B = (\textwidth) – (width of node A)

I think the answer I am looking for is hidden somewhere in this answer.

Best Answer

Did I understand correctly?

\documentclass[border=5mm,tikz]{standalone}
\usetikzlibrary{calc}
\usepackage{lipsum}
\begin{document}

\begin{tikzpicture}
\foreach\j in {1,10,100}{
\node[outer sep=0] (a-\j) at (0,{-7*log10(\j)}) {\j};
\path let \p1=($(a-\j.east)-(a-\j.west)$) 
  in 
  node[anchor=west,text width=\textwidth-\x1] (b-\j) at (a-\j.east) 
    {\lipsum[1]};
}
\end{tikzpicture}
\end{document}

enter image description here