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.
\documentclass{article}
\usepackage{tikz}

\begin{document}
\pagenumbering{gobble}

\hskip-1.25in
\begin{tikzpicture}[thick,fill opacity=.4,draw opacity=1]
%\draw[step=1cm] (-9,-9) grid (9,9);
%\filldraw[fill=black,fill opacity=1] (0,0) circle (.5mm);
\draw[fill=yellow] (-9,-8) rectangle (9,8);
\draw[fill=orange,dashed] (-3,-5) rectangle (9,5);
\draw[fill=green,dotted] (-3,-4) rectangle (5,4);
\draw[fill=red] (-9,-6) rectangle (2,6);
\draw[fill=blue] (-6,-2) rectangle (0,2);
\end{tikzpicture}

\end{document}

leaves the borders of the superimposed rectangles with different thicknesses/opacities (as you can see below).

enter image description here

How can I set the thicknesses of each rectangle to show up through the more transparent fill? I thought this is what draw opacity=1 would accomplish.

share|improve this question
    
(I don’t understand your question.) What is your problem? What did you expect to see? Can you simplify your example to two or three paths? The draw opacity key simply sets the opacity of the stroked path. The fill opacity sets the opacity of filled path. A value of 0 indicates invisibility (full see-through), a value of 1 means that nothing shines through. –  Qrrbrbirlbel Nov 6 '13 at 19:36
add comment

1 Answer

up vote 4 down vote accepted

draw opacity=1 does indeed draw opaque lines, but the appearance will be affected if you then place something in front (on top?) of that object. You can thus change the order in which you draw objects to emphasize their appearance.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[thick,fill opacity=.4,draw opacity=1]
\draw[fill=yellow] (-9,-8) rectangle (9,8);
\draw[fill=red] (-9,-6) rectangle (2,6);
\draw[fill=orange,dashed] (-3,-5) rectangle (9,5);
\draw[fill=green,dotted] (-3,-4) rectangle (5,4);
\draw[fill=blue] (-6,-2) rectangle (0,2);
\end{tikzpicture}
\end{document}

Another option is to draw the filled parts first and the borders last, to ensure the border lines are not obscured.

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[thick,fill opacity=.4,draw opacity=1]
\fill[yellow] (-9,-8) rectangle (9,8);
\fill[red] (-9,-6) rectangle (2,6);
\fill[orange,] (-3,-5) rectangle (9,5);
\fill[green,dotted] (-3,-4) rectangle (5,4);
\fill[blue] (-6,-2) rectangle (0,2);
%
\draw (-9,-8) rectangle (9,8);
\draw (-9,-6) rectangle (2,6);
\draw[dashed] (-3,-5) rectangle (9,5);
\draw[dotted] (-3,-4) rectangle (5,4);
\draw (-6,-2) rectangle (0,2);
\end{tikzpicture}
\end{document}
share|improve this answer
    
Not a very elegant solution though. Maybe someone else knows a better way. –  erik Nov 6 '13 at 20:52
    
Worked just fine for me and was easy to implement. Thanks. –  JohnD Nov 6 '13 at 23:03
add comment

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.