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.

I am trying to draw a shaded triangle with tikz, using the following code:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\fill[top color=green!40,middle color=white,shading angle=45]  (-2.5,-3) -- (12.5,3) -- (-2.5,3) -- cycle;
\end{tikzpicture}
\end{document}

I think it is hard to see in the image posted below, but just along the diagonal is a very thin line. Is there any way to get rid of this line?

This is with Tikz/PGF version 2.10.

tikz compiled image

share|improve this question
    
you can find out your pgf version by putting a \listfiles command into the preamble of your document. This will write all invoked packages and classes as well as their version into the log file. –  Benedikt Bauer Nov 7 '12 at 13:46
    
I think you should try with \draw[top color=green!40,middle color=white,shading angle=45,draw=none] (-2.5,-3) -- (12.5,3) -- (-2.5,3) -- cycle;. Does it fix the problem? –  Claudio Fiandrino Nov 7 '12 at 13:49
    
If this is going to be some sort of a header use the whole page not the triangle itself. –  percusse Nov 7 '12 at 13:50
    
@ClaudioFiandrino, yes, this works well. –  silvado Nov 7 '12 at 13:51
    
@BenediktBauer, thanks, I updated the information. –  silvado Nov 7 '12 at 13:54
add comment

1 Answer

up vote 4 down vote accepted

Use \shade instead of \fill.

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade[top color=green!40,middle color=white,shading angle=45]  (-2.5,-3) -- (12.5,3) -- (-2.5,3) -- cycle;
\end{tikzpicture}
\end{document}

enter image description here

As noted by Paul replacing \fill by \path would also work:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\path[top color=green!40,middle color=white,shading angle=45]  (-2.5,-3) -- (12.5,3) -- (-2.5,3) -- cycle;
\end{tikzpicture}
\end{document}
share|improve this answer
    
@PaulGaborit The thing is so complex and I have trouble understanding your comment/objection :-) Can you shed some more light on it? You may feel free to edit the answer itself, if you feel appropriate. I appreciate your effort. Thanks. –  Harish Kumar Nov 7 '12 at 23:03
1  
The problem is not to use or not to use \shade (top color always selects the shade option). The problem is to mix it with a fill operation. A simple \path instead of \fill is sufficient. –  Paul Gaborit Nov 8 '12 at 1:16
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.