2

I'm trying to fit the nodes one and two belonging to a parted node, in order to encapsulate them inside a rectangle with a different color:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains}
\usetikzlibrary{shapes}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{fit}

\begin{document}
    \begin{tikzpicture}
        \node (qs) [draw,font=\tiny,
        rectangle split,
        rectangle split parts=3,
        text centered,
        align=center,
        ] at (-2.3,0) {%
            \nodepart{one} one
            \nodepart{two} two
            \nodepart{three} three
        };
        
        \node[fit=(qs.one above left)(qs.two),rectangle,draw=red,line width=1mm] {};
        \node[fit=(qs.one north west)(qs.two),rectangle,draw=red,line width=1mm] {};
    \end{tikzpicture}
\end{document}

By the way, it recognizes neither above left nor north west. What is the best solution to draw this border with the correct coordinates?

Package PGF Math Error: Unknown function `one' (in 'one above left'). ...qs.two),rectangle,draw=red,line width=1mm]

Package PGF Math Error: Unknown function `one' (in 'one north west'). ...qs.two),rectangle,draw=red,line width=1mm]

1
  • multi part node doesn't have anchor .one north west ... instead it you should use .north west.
    – Zarko
    Dec 27, 2016 at 1:46

1 Answer 1

2

I suspect, that you looking for

enter image description here

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains,
                fit,
                shapes,
                shapes.multipart}

\begin{document}
    \begin{tikzpicture}[
F/.style = {draw=red, line width=1mm, inner sep=0mm}
                        ]
\node (qs) [draw,font=\tiny,
            rectangle split,
            rectangle split parts=3,
            text centered,
            align=center] at (-2.3,0) {%
    \nodepart{one} one
    \nodepart{two} two
    \nodepart{three} three
};

\node[F, fit=(qs.north west) (qs.two split east)] {};
    \end{tikzpicture}
\end{document}

Edit: now images is corrected as requested in comment.

2
  • Actually, I'd prefer to group one and two inside a same box/frames, and not to split such box into two parts. I'm doing this because in my original example boxes are already colored, and box/frames only hilights the steps of my algorithm.
    – jackb
    Dec 27, 2016 at 10:23
  • @jackb, answer is corrected.
    – Zarko
    Dec 27, 2016 at 12:33

You must log in to answer this question.

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