51

Is there a simple way to create a transparent node with opaque text? Preferably without having to use a postaction or redraw the node.

In the example below I'd like to achieve the effect of the first three nodes, without redrawing the second node to create the opaque text:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    % desired effect:
    \node [fill=red,circle,minimum size=6mm,inner sep=0mm] {};
    \node [right,fill=green,opacity=.2] {Node};
    \node [right] {Node};

    % undesired effect:
    \node at(2,0) [fill=red,circle,minimum size=6mm,inner sep=0mm] {};
    \node at(2,0) [right,fill=green,opacity=.2] {Node};
\end{tikzpicture}
\end{document}

example

74

After setting the opacity, you have to reset the text opacity=1 to get opaque text. The opacity key is a shorthand for setting the draw opacity and the fill opacity at the same time, and the fill opacity in turn automatically applies to the text opacity.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    % undesired effect:
    \node at(2,0) [fill=red,circle,minimum size=6mm,inner sep=0mm] {};
    \node at(2,0) [right,fill=green,opacity=.2,text opacity=1] {Node};
\end{tikzpicture}
\end{document}

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.