4

Perhaps this is a bug or a version problem, but the filling of the second part of a 2-part rectangle goes outside the box.

Or I'm overlooking something?

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\tikzset{
    llnode/.style = {
        draw,
        very thick,
        rectangle split,
        rectangle split parts = 2,
        rectangle split,
        rectangle split part fill = {none, orange},
        rectangle split empty part width = 0.15cm,
    }
}

\begin{document}


\usetikzlibrary {shapes.multipart}
\begin{tikzpicture}[transform shape, scale = 8]
    \fill[red] (0.25, 0) circle (0.3);
    \node [llnode] (-1, 0){A\nodepart{two}B};
    \node [llnode, rectangle split horizontal] at (1, 0) {C\nodepart{two}D};
\end{tikzpicture}

\end{document}

Note that the orange escapes the borders.

enter image description here

If I fill the first part the problem is gone, but I need the first part to be transparent. Maybe there's a way to fill it with white and zero opacity.

1
  • That solution of yours would probably work but is definitely a cheat ;)
    – SebGlav
    Mar 11, 2021 at 19:13

2 Answers 2

8

It is a bug in the pgflibraryshapes.multipart.code.tex library, which uses the outer sep incorrectly. A work around is to set outer sep to 0. You may want to report an issue.

\documentclass[12pt,a4paper]{article}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\tikzset{
    llnode/.style = {
        draw,
        very thick,outer sep=0pt,
        rectangle split,
        rectangle split parts = 2,
        rectangle split part fill = {none, orange},
        rectangle split empty part width = 0.15cm,
    }
}

\begin{document}


\usetikzlibrary{shapes.multipart}
\begin{tikzpicture}[transform shape, scale = 8]
    \fill[red] (0.25, 0) circle (0.3);
    \node [llnode] (-1, 0){A\nodepart{two}B};
    \node [llnode, rectangle split horizontal] at (1, 0) {C\nodepart{two}D};
\end{tikzpicture}

\end{document}

enter image description here

1
  • Setting outer sep to zero won't affect anything else in my drawing, so the answer is accepted.
    – Jander
    Mar 12, 2021 at 12:12
2

hm, if can be part of node, which you not like to color, colored white? In this case you can obtain:

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\tikzset{
    llnode/.style = {
        draw,
        very thick,
        rectangle split,
        rectangle split parts = 2,
        rectangle split part fill = {white, orange},
        rectangle split empty part width = 0.15cm,
    }
}

\begin{document}
    \begin{tikzpicture}[transform shape, scale = 4]
\fill[red] (-1, 0) circle (0.3);
%
\node [llnode] at (0, 0){A\nodepart{two}B};
\node [llnode, rectangle split horizontal] at (1, 0) {C\nodepart{two}D};
    \end{tikzpicture}
\end{document}

It seems that your selection for fill color none cause shift of fill in colored part of node. This may be considered as bug.

Edit: if you remove scale from tikzpicture options, this problem -- bug -- using rectangle split part fill = {none, orange} disappear (in this case transform shape hasn't sense) .

1
  • Filling with white won't allow transparency, what I need em some cases. In this case, transform shape and scale was just to make the issue more visible; the problem doesn't disappear, but I agree it is minimized.
    – Jander
    Mar 12, 2021 at 12:10

You must log in to answer this question.

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