I am trying to make a schematic, where I need to have a rectangle with the minimum width set to the distance between two other rectangle nodes.
I tried to follow the solutions from Compute the x distance between two nodes post, but in that case I always end up with the following error
Illegal parameter number in definition of \iterate. \end{frame}
I guess I forgot something, but cannot figure out what.
Here is what I am trying to do:
My problem is to get the green and red rectangles width. Here is what I have so far:
\documentclass[aspectratio=169, 14pt, notes]{beamer}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, fit, graphs, math, positioning, shapes, shadows, tikzmark}
\begin{frame}[t]
\frametitle{My frame}
\framesubtitle{Example}
\newcommand\setxveclength[5]{% newmacro, node1, anchor1, node2, anchor2
\pgfpointdiff{\pgfpointanchor{#2}{#3}}{\pgfpointanchor{#4}{#5}}
\edef#1{\the\pgf@x}
}
\begin{tikzpicture}[remember picture, overlay]
\node[inner sep=0pt, minimum width=0.30cm, minimum height=2.50cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny] (PartA) at ({$(current page.west)!0.25!(current page.east)$} |- {$(current page.north)!0.50!(current page.south)$}) {\rotatebox{270}{AAA}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=2.50cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=west] (PartB) at ([xshift=0.50mm]PartA.east) {\rotatebox{270}{BBB}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=2.50cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=west] (PartC) at ([xshift=0.50mm]PartB.east) {\rotatebox{270}{CCC}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=1.66cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=south west] (PartD)at ([xshift=0.50mm]PartC.south east) {\rotatebox{270}{DDD}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=1.66cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=west] (PartE) at ([xshift=0.50mm]PartD.east) {\rotatebox{270}{EEE}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=1.66cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=west] (PartF) at ([xshift=0.50mm]PartE.east) {\rotatebox{270}{FFF}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=2.50cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=south west] (PartG)at ([xshift=0.50mm]PartF.south east) {\rotatebox{270}{GGG}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=2.50cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=west] (PartH) at ([xshift=0.50mm]PartG.east) {\rotatebox{270}{HHH}};
\node[inner sep=0pt, minimum width=0.30cm, minimum height=2.50cm, rounded corners=0.10cm, draw=gray4, fill=gray5, text=white, font=\tiny, anchor=west] (PartI) at ([xshift=0.50mm]PartH.east) {\rotatebox{270}{III}};
\setxveclength{\mydist}{LinuxComp_Tel}{west}{ActiaSoft_GNSS}{east}
\node[inner sep=0pt, minimum width=\pgfpointdiff{\pgfpointanchor{PartD}{west}}{\pgfpointanchor{PartF}{east}}, minimum height=0.30cm, rounded corners=0.10cm, draw=gray4, fill=GreenActia, text=white, font=\tiny, anchor=south west] (PartJ) at ([yshift=0.50mm]PartD.north west) {JJJ};
\end{tikzpicture}
\end{frame}
I notice that the problem appears as soon as I declare the \newcommand. I do not need to invoke it
I found this solution creating the node the following way:
\path let \p1=($(PartD.west)-(PartF.east)$), \n1 = {veclen(\p1)}
in node[inner sep=0pt, minimum width=\n1, minimum height=0.30cm, rounded corners=0.10cm, draw=gray4, fill=green4, text=white, font=\tiny, anchor=south west, name=PartJJJ] at ([yshift=0.50mm]PartD.north west) {JJJ};
But in that case I cannot reuse the distance for a second node, that would mean that I have to recalculate the width each time, and make sure the node taken for the calculation are accurate for each rectangle with this particular width.
Thanks for the help,




ninecolorspackage. I added this to my answer. Sorry, I first thought that your main question was about how to get this distances into theminimum widthoption, so I did not care about thebeamercontext – Jasper Habicht Mar 31 '23 at 20:48@in its name without using\makeatletter. – Qrrbrbirlbel Mar 31 '23 at 23:51#…inside a frame, it will need the optionfragileto work (or you move the definition of\setxveclengthin the preamble where it belongs). – Qrrbrbirlbel Apr 01 '23 at 00:45newcommandin the preamble, and it started to work. As for the\makeatletterand\makeatotherI tried it, but since it was not in the preamble I still got the error. Of course, in the preamble, I had to add it too for the whole thing to work. Thanks – Krzysztof Apr 01 '23 at 18:15