[Tex/LaTex] TikZ multipart nodes: How to set text attributes (opacity) for some/all parts

tikz-pgftransparency

I am using TikZ with the rectangle split multipart node (detailed on pp 450ff in the PGF 2.1 documentation). I need to influence the text opacity of all parts, but whatever I try seems to work only on the text (=first) part of the multipart node:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

\begin{document}
  \begin{tikzpicture}
    \node[rectangle split, rectangle split parts=2, draw, text opacity=0.5]{%
      transparent :-)
      \nodepart{two}
      not transparent :-(
    };
  \end{tikzpicture}
\end{document}

results in:

enter image description here

I have also tried \nodepart[text opacity=0.5]{two} and even Heiko Oberdiek's transparent package to set the text transparency manually, which, however does not seem to play together with PGF. There also seem to be no every ... styles for the additional parts of the rectangle split node.

I must be overlooking something.

Best Answer

I submitted a bug report at the Sourceforge page.

A temporary workaround would be to put the following into your preamble:

\makeatletter
\def\tikz@nodepart@continue{%
  \global\let\tikz@fig@continue=\tikz@fig@continue@orig%
  % Now start new box:
   \expandafter\setbox\csname pgfnodepart\tikz@nodepart@name box\endcsname=\hbox%
      \bgroup%
        \tikzset{every \tikz@nodepart@name\space node part/.try}%
        \expandafter\tikzset\expandafter{\tikz@nodepart@options}%
        % ---- begin added lines
        \ifx\tikz@textopacity\pgfutil@empty%
        \else%
          \pgfsetfillopacity{\tikz@textopacity}%
          \pgfsetstrokeopacity{\tikz@textopacity}%
        \fi%
        % ---- end added lines
        \pgfinterruptpicture%
          \tikz@textfont%  
          \ifx\tikz@text@width\pgfutil@empty%
          \else%
            \begingroup%
                \pgfmathsetlength{\pgf@x}{\tikz@text@width}%
              \pgfutil@minipage[t]{\pgf@x}\leavevmode\hbox{}%
                \tikz@text@action%
          \fi%
          \bgroup%
            \aftergroup\unskip%
            \ifx\tikz@textcolor\pgfutil@empty%
            \else%
              \pgfutil@colorlet{.}{\tikz@textcolor}%
            \fi%
            \pgfsetcolor{.}%
            \setbox\tikz@figbox=\box\pgfutil@voidb@x%
            \tikz@uninstallcommands%
            \tikz@atbegin@node%
            \aftergroup\tikz@fig@collectresetcolor%
            \tikz@halign@check%
            \ignorespaces%
}
\makeatother

Everything except for the marked code is copied from tikz.code.tex (the marked code is also from that file, but taken from the definition of \tikz@do@fig).

With this your code produces
correct result