Tikz 树中子项的不透明填充颜色。如何保持文本不透明?

Tikz 树中子项的不透明填充颜色。如何保持文本不透明?

我正在创建一个带有节点和子节点的层次 tikz 图。我想特别强调一条路径,并用不透明的颜色为这条路径着色。问题是文本也是不透明的。我尝试使用这个blend mode=multiply技巧,但似乎在这里不起作用。有什么想法吗?

平均能量损失

\documentclass[11pt]{beamer}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\usetikzlibrary{calc}

\begin{document}

\begin{frame}{MWE}
    \begin{figure}
        \begin{tikzpicture}[
            sibling distance=7em,
            level distance=4em,
            every node/.style={
                draw,
                align=center,
                minimum height=5ex,
                execute at end node=\vphantom{p},
                font=\footnotesize,
                shape=rectangle}
                ]
        \node[draw=black, fill=blue, fill opacity=0.2, blend mode=multiply]{\footnotesize vfewgfwegwegwe \\ \footnotesize (gwegwe)}
            child{node{\footnotesize ewgegweg \\ \footnotesize egweg}}
            child{node{\footnotesize gwegweweg \\ \footnotesize ewgweg}}
            child{node[draw=black, fill=blue, fill opacity=0.2, blend mode=multiply]{\footnotesize Eewgewgwet \\ \footnotesize iwegw}
                child{node{\footnotesize wegweg \\ \footnotesize swegwegwe}}
                child{node[draw=black, fill=blue, fill opacity=0.2, blend mode=multiply]{\footnotesize Hirwegwe \\ \footnotesize wegwegweg}
                    child{node[draw=black, fill=blue, fill opacity=0.2, blend mode=multiply]{\footnotesize wegweg \\ \footnotesize wegwe}}
                    child{node{\footnotesize genew \\ \footnotesize wegweg}}}
                child{node{\footnotesize egwg \\ \footnotesize gwegw}}}
            child{node{\footnotesize ewgeg \\ \footnotesize gwegwe}};
        \end{tikzpicture}
    \end{figure}
\end{frame}
    
\end{document}

输出

在此处输入图片描述

答案1

根据我对您上一个问题的回答。在选定节点中,您只需添加fill=<selected color>,例如:fill=blue!15

  • forest
\documentclass[11pt]{beamer}
\usepackage{forest}

\begin{document}

\begin{frame}{MWE}
    \begin{figure}
\begin{forest}
for tree = {
% nodes
    draw, 
where level=0{text width=8em, fill=blue!15}{text width=5em}, 
    text centered,
    minimum height=6ex, 
    execute at end node=\vphantom{p},
    font=\footnotesize,
% tree
    anchor=north,
    l sep=12mm,
    s sep=2mm,
            }
[vfewgfwegwegwe (gwegwe)
    [ahsfafasd  aasfasf]
    [Trasfas  asfasms]
    [afst incasfasves,fill=blue!15
        [asfasf supplements5]
        [Hfass fasfas,fill=blue!15
            [wegeg wegweg, fill=blue!15]
            [genew genew]            
        ]
        [sfasdf fasfas]
    ]
    [efaecfasd joasfas]
]
\end{forest}
    \end{figure}
\end{frame}

\end{document}

在此处输入图片描述

  • tikz
\documentclass[11pt]{beamer}
\usepackage{tikz}

\begin{document}

\begin{frame}{MWE}
    \begin{figure}
\begin{tikzpicture}[
    sibling distance=6em,
    level distance=5em,
    every node/.style={draw,
                       text width=5em, align=center,
                       minimum height=6ex,
                       execute at end node=\vphantom{p},
                       font=\footnotesize}
                    ]
\node[fill=blue!15] {vfewgfwegwegwe (gwegwe)}
    child{node{ahsfafasd  aasfasf}}
    child{node{Trasfas  asfasms}}
    child{node[fill=blue!15]{afst incasfasves}
        child{node{asfasf supplements}}
        child{node[fill=blue!15]{Hfass fasfas}
            child{node[fill=blue!15]{wegeg wegeg}}
            child{node{genew genew}}
             }
        child{node{sfasdf fasfas}}
        }
    child{node{efaecfasd joasfas}};
        \end{tikzpicture}
    \end{figure}
\end{frame}

\end{document}

在此处输入图片描述

相关内容