1

Consider this code, which is a simplified version of this answer:

\documentclass[tikz,margin=3mm]{standalone}
\def\innersep{.3333em}
\begin{document}
\begin{tikzpicture}[every node/.style={draw,text centered}]
\node[minimum height=6*\baselineskip+2*\innersep] (c1-r1) {Output index 1}; % The origin
\draw (c1-r1.south) node[below,minimum height=6*\baselineskip+2*\innersep] (c1-r2) {Output index 2};
%%%%%%%%%%%%%%%%%%%%%%%%
% TAKE NOTE OF THIS LINE
\draw (c1-r2.south) node[below,minimum height=18*\baselineskip+6*\innersep] (c1-r3) {Output index 3};
%%%%%%%%%%%%%%%%%%%%%%%%
\foreach \i in {1,2} {
    \draw (c1-r\i.north east) node[below right,minimum height=3*\baselineskip+\innersep] (c2-r\i-1) {Inner index \i.1};
    \draw (c1-r\i.south east) node[above right,minimum height=3*\baselineskip+\innersep] (c2-r\i-2) {Inner index \i.2};
}
\draw (c1-r3.north east) node[below right,minimum height=3*\baselineskip+\innersep] (c2-r3-1) {Inner index 3.1};
\foreach \i/\j in {2/1,3/2,4/3,5/4,6/5} {
    \draw (c2-r3-\j.south) node[below,minimum height=3*\baselineskip+\innersep] (c2-r3-\i) {Inner index 3.\i};
}
\end{tikzpicture}
\end{document}

A part of the output:

enter image description here

We can see that the height of node {Output index 3} is slightly smaller than it should be. However, we can prove that the above code is correct:

Consider node {Output index 1} or {Output index 2}. The height of both of them are 6*\baselineskip+2*\innersep. Each of them is twice as high as the {Inner index x.y} nodes.

Now the node {Output index 3} is supposed to be six times as high as the {Inner index x.y} nodes, or, equivalently, three times as high as {Output index 1} or {Output index 2}.

Therefore, the height of node {Output index 3} is

3 * (6*\baselineskip + 2*\innersep) = 18*\baselineskip + 6*\innersep

or the above code is correct.

What's wrong?


In the linked answer, I use 18*\baselineskip+6.6*\innersep, however I know it is only an approximation. I want to have an accurate number!

Thanks in advance.

1 Answers1

3

You are forgetting the lines. In this case 5*\pgflinewidth:

\documentclass[tikz,margin=3mm]{standalone}
\def\innersep{.3333em}
\begin{document}
\begin{tikzpicture}[every node/.style={draw,text centered}]
\node[minimum height=6*\baselineskip+2*\innersep] (c1-r1) {Output index 1}; % The origin
\draw (c1-r1.south) node[below,minimum height=6*\baselineskip+2*\innersep] (c1-r2) {Output index 2};
%%%%%%%%%%%%%%%%%%%%%%%%
% TAKE NOTE OF THIS LINE
\draw (c1-r2.south) node[below,minimum height=18*\baselineskip+6*\innersep+5*\pgflinewidth] (c1-r3) {Output index 3};
%%%%%%%%%%%%%%%%%%%%%%%%
\foreach \i in {1,2} {
    \draw (c1-r\i.north east) node[below right,minimum height=3*\baselineskip+\innersep] (c2-r\i-1) {Inner index \i.1};
    \draw (c1-r\i.south east) node[above right,minimum height=3*\baselineskip+\innersep] (c2-r\i-2) {Inner index \i.2};
}
\draw (c1-r3.north east) node[below right,minimum height=3*\baselineskip+\innersep] (c2-r3-1) {Inner index 3.1};
\foreach \i/\j in {2/1,3/2,4/3,5/4,6/5} {
    \draw (c2-r3-\j.south) node[draw=red,below,minimum height=3*\baselineskip+\innersep] (c2-r3-\i) {Inner index 3.\i};
}
\end{tikzpicture}
\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Oh, I didn't realize it :) Why could I forget the lines. Thank you very much! Anyway in the actual answer I did not use any lines, so luckily I don't have to change anything. –  Mar 21 '19 at 13:43