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.

When I use the tikz key opacity for a polygon in a tikzpicture, it applies to the drawn fill as well as to the draw lines.

I would like to have it this way that the lines remain untouched by the opacity key, so that they behave as if they had opacity=1.

(What I do now is redraw the polygon with fill=none, but that is a crippled solution to the problem).

share|improve this question

1 Answer 1

up vote 56 down vote accepted

You can specify the fill opacity separately form the draw opacity. In the first example below I used opacity and in the second I used fill opacity which will only affect the fill and not the draw.

enter image description here


  • As pointed out by Martin Scharrer: Specifying \opacity=<x> affects both the fill and draw so is equivalent to saying fill opacity=<X>, draw opacity=<X>.
  • fill opacity applies not only to the fill, but also applies to text. To override this behavior, you can separately set the text opacity which applies only to the text labels.


    \draw [ultra thick, draw=black, fill=yellow, opacity=0.2]
       (0,0) -- (0,1) -- (1,1) -- cycle;
    \draw [ultra thick, draw=black, fill=yellow, fill opacity=0.2]
       (0,0) -- (0,1) -- (1,1) -- cycle;
share|improve this answer
It should be noted that opacity=<X> is just a short-cut for fill opacity=<X>,draw opacity=<X>. Both are actual to different low-level settings in the output file (e.g. PDF). –  Martin Scharrer Dec 21 '11 at 18:52
@MartinScharrer: Good point. Have added a note incorporating your comment. –  Peter Grill Dec 21 '11 at 19:09
wow, sometimes things can be so easy... I thought I had already tried that. Great! –  romeovs Dec 21 '11 at 20:54

Your Answer


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.