4

I'm using a matrix to put the nodes in a Tikz diagram:

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone}
\usepackage{tikz, calc}
\usepackage{array}


\begin{document}
    \begin{tikzpicture} [
    auto,   
    fblk/.style    = { rectangle, draw=gray, fill=pink!30, text width=4.5em, text centered, minimum height=1em },
    %ffblk/.style    = { rectangle, draw=gray, fill=pink!30, text width=4.5em, text centered,   minimum height=1em },
    ]

    \matrix [column sep=2.3em, row sep=1.em] {
        \node[fblk](f1){FBLK1}; && \node[fblk](f2){FBLK2};\\
        & \node[fblk](f3){FBLK3}; \\
    %    \node[ffblk](f4){FBLK1}{FBLK2}; \\
    };
    \end{tikzpicture}
\end{document}

Now, I want define a new node style, ffblk that has 2 adjoing rectangles. This node style takes two arguments, each for each rectangles. See the image.

I tried to manage this by adding xshift=-... to the next node; and by making column sep=0em. But I could not create what I wanted.

4

Maybe something like this, using the shapes.multipart library ?

\documentclass[tikz,border=1mm]{standalone}
\usetikzlibrary{shapes.multipart}
\begin{document}
\begin{tikzpicture}[fblk/.style={rectangle split, rectangle split horizontal, rectangle split parts=2, draw, anchor=center, draw=gray, fill=pink!30}]
\node [fblk] {FBLK1\nodepart{two}FBLK2};
\end{tikzpicture}
\end{document}

Output

enter image description here

6

When two adjacents nodes in a matrix should share a border line, row sep and|or column sep should be fixed to -\pgflinewidth:

\documentclass[border={0pt 0pt 0pt 0pt}]{standalone}
\usepackage{tikz, calc}
\usepackage{array}


\begin{document}
    \begin{tikzpicture} [
    auto,   
    fblk/.style    = { rectangle, draw=gray, fill=pink!30, text width=4.5em, text centered, minimum height=1em },
    ]

    \matrix [column sep=-\pgflinewidth, row sep=-\pgflinewidth] {
        \node[fblk](f1){FBLK1}; & \node[fblk](f2){FBLK2};\\
        & \node[fblk](f3){FBLK3}; \\
    %    \node[ffblk](f4){FBLK1}{FBLK2}; \\
    };
    \end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.