Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 33 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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