I am using following solution How to split tikz rectangle by half with different colors and text lines. On top of this solution is it possible to split a row into two and color it differently?

@Torbjørn T. solution from the linked answer:

       rectangle split,
       rectangle split parts=2,
       rectangle split part fill={red!30,blue!20},
       rounded corners,
       draw=black, very thick,
       minimum height=2em,
       text width=3cm,
       inner sep=2pt,
       text centered,
\node [state] {text\\txet \nodepart{two} blue background \\ here};

wanted output:

| red | white |
|    blue     |

enter image description here


2 Answers 2


Similar to @anis answer, but code reproduce in question showed image:

enter image description here

sectors/.style n args={8}{minimum width=#1, minimum height=#2, 
                          text depth=0.25ex, outer sep=0pt,
                          append after command={\pgfextra{\let\LN\tikzlastnode
    \draw[fill=#3]  (\LN.west)  -| (\LN.north)
                    {[rounded corners=3mm] -- (\LN.north west)}
                                |- cycle;
    \draw[fill=#5]  (\LN.north)  |- (\LN.east)
                    {[rounded corners=3mm] -- (\LN.north east)}
                                -- cycle;
    \draw[fill=#7]  (\LN.west)  {[rounded corners=3mm] |- (\LN.south east)} 
                                |- cycle;
    \path   (\LN.center) -- node[align=center] {#4} (\LN.north west) 
            (\LN.center) -- node[align=center] {#6} (\LN.north east) 
            (\LN.center) -- node[align=center] {#8} (\LN.south);
                     } } }
    \node [sectors= {32mm}{24mm}
                    {red!30}{text\\ text}
                    {blue!30}{blue bacground\\ here}] {};

However, I suspect that you looking for general building blocks (BB), by which you can to compose any blocks structure:

  • Is this is a case, you should be aware that splitting of nodes to subnodes is very hard task.
  • Far more simple is connect nodes (BB), tight to each other, in desired connections.
  • In this is drawing further simpler, if nodes shapes are rectangles with sharp corners (than is sufficient to define only one BB),
  • For further/better help, please show us an example of structure(s) which you like to draw.
  • Below is an example of composition with simple building blocks of rectangle shape:

enter image description here


 node distance = 0pt,
BB/.style args={#1/#2/#3}{% Building Box, options
        draw, semithick, 
        font=\small\linespread{0.84}\selectfont, align=center, 
        minimum width=#1, minimum height=#2, text depth=0.25ex, 
        fill=#3, outer sep=0pt}
            } % end of tikzset
    \node (L1)  [BB=32mm/8mm/teal!30] {basic layer};
    \node (L2)  [BB=32mm/8mm/yellow!30,
                 above=of L1] {second layer};
    \node (L31) [BB=16mm/12mm/red!30,
                 above right=of L2.north west] {third\\ level\\ first};
    \node (L32) [BB=16mm/12mm/orange!30,
                 right=of L31] {third\\ level\\ second};


Here is my adaptation of this solution: How create circle node in Tikz with T from lines inside? T made split node to 3 sectors

I just added rectangles to fill the space inside the node. enter image description here


    \tikzset{sectors/.style n args={6}{%
            minimum width=#4,
            minimum height=#5,
            append after command={%
                \pgfextra{ %
                    \draw (\tikzlastnode.center) -- (\tikzlastnode.south) ;
                    \draw (\tikzlastnode.west)   -- (\tikzlastnode.east) ;
                    \draw[fill = blue] (\tikzlastnode.west) rectangle (\tikzlastnode.north east);  
                    \path (\tikzlastnode.center) -- node[#6] {#1} (\tikzlastnode.north); 
                    \draw[fill = cyan] (\tikzlastnode.center) rectangle (\tikzlastnode.south west);  
                    \path (\tikzlastnode.center) -- node[#6] {#2} (\tikzlastnode.south west); 
                    \draw[fill = green] (\tikzlastnode.center) rectangle (\tikzlastnode.south east);  
                    \path (\tikzlastnode.center) -- node[#6] {#3} (\tikzlastnode.south east);
                 } }}}
    \begin{tikzpicture}[ultra thick]
    \node [sectors={1}{2}{3}{5cm}{5cm}{font=\Huge\bfseries,text=red}]  (c)  {};
  • What should I do if there are 3 rows?
    – alper
    Jan 6 at 17:11

You must log in to answer this question.

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