4

I want to have same height for the splitted rectangle's rows. Their height changes based on the character inside each section, for example . is much smaller than having larger characters like f.

my code:

\documentclass[5p,times]{elsarticle}
\usepackage{tikz}
\usetikzlibrary{
    chains,
    positioning,
    shapes.geometric,
    shapes
}
\begin{document}
\section{Example}
\noindent
\begin{tikzpicture}[
        data/.style={
                draw,
                rectangle split,
                rectangle split parts=4,
                text centered,
                font=\scriptsize
            }
    ]
    \node [data,label=below:{test}] (n1) {
            GOOGLE
            \nodepart{second} IPFS
            \nodepart{third} ipfs
            \nodepart{fourth} .
        };
\end{tikzpicture}
\end{document}

output:

enter image description here

Here all the sections have different height, for example forth row is much smaller. Is it possible to make all rows same height?

Could be related to: How to set rectangle split with the same size (width and height)?

5
  • 2
    You can add a \strut to the text in each row. I wonder if there is an every part/.style? Jul 19, 2022 at 13:29
  • Take a look at this solution: tex.stackexchange.com/a/651341/6880 .
    – projetmbc
    Jul 19, 2022 at 13:47
  • Strangely, there seems to be no every part/.style. Additionally, it seems not to be possible to set minimum height to the node parts, at least not in vertical orientation: "When split vertically, the rectangle split will meet any minimum width requirements, but any minimum height will be ignored" (page 820, TikZ manual). Jul 19, 2022 at 14:03
  • @JohnKormylo thanks using ` \strut` helped to format text in each row.
    – alper
    Jul 19, 2022 at 14:51
  • nicematrix and tabularray should be good for this kind of diagram.
    – projetmbc
    Jul 19, 2022 at 15:13

1 Answer 1

5

The straight-forward approach would be to apply minimum height to the nodes. But as the TikZ manual states (on page 820 of the current version):

When split vertically, the rectangle split will meet any minimum width requirements, but any minimum height will be ignored.

However, as stated in the comments, you can add \strut to the contents of each of the nodes. You can use the following approach to do this automatically using execute at begin node:

\documentclass[5p,times]{elsarticle}
\usepackage{tikz}
\usetikzlibrary{
    chains,
    positioning,
    shapes.geometric,
    shapes
}
\begin{document}
\section{Example}
\noindent
\begin{tikzpicture}[
    data/.style={
            draw,
            rectangle split,
            rectangle split parts=4,
            text centered,
            font=\scriptsize,
            execute at begin node=\strut
        }
    ]
    \node [data,label=below:{test}] (n1) {
        GOOGLE
        \nodepart{second} IPFS
        \nodepart{third} ipfs
        \nodepart{fourth} .
    };
\end{tikzpicture}
\end{document}

enter image description here

2
  • Can I use inner ysep=1pt to make height for all rows little bit smaller?
    – alper
    Jul 19, 2022 at 15:17
  • Sure, this should work fine. Jul 19, 2022 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .