Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TikZ and shading a rectangle

1,556 views
Skip to first unread message

Stefan Schulze Frielinghaus

unread,
May 7, 2010, 11:20:36 AM5/7/10
to
Hello all,

I'm trying to create a rectangle with a color gradient. While using the
following code the rectangle gets a (blue) colored line at the left
side:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade[left color=white, right color=blue]
(0,0) rectangle +(9cm,2cm);
\shade[left color=white, right color=blue!20]
(0,3cm) rectangle +(9cm,2cm);
\end{tikzpicture}
\end{document}

What is even more strange is that the line on the left changes as soon
as the color is modified to "blue!20" (the line gets wider).

I wouldn't expect a blue line at the left nor is it desired in my case.
Is it possible to create a rectangle with a color gradient without a
border at some side? At the moment I use a hack and create a white
rectangle in front of the left border. Something like this:

\draw[color=white, fill=white] (0,0) rectangle +(1mm,2cm);

But this is not really flexible and more like a hack. Even in the manual
of TikZ the issue arises, see manual version 2.0 on page 28. The
rectangle shading from yellow to black has at the top side a black line
which stands out because the yellow part starts there, too.

Is there some convenient/elegant solution outside?

Cheers,
Stefan

Paul Gaborit

unread,
May 7, 2010, 11:53:16 AM5/7/10
to

� (at) Fri, 07 May 2010 17:20:36 +0200,
Stefan Schulze Frielinghaus <schu...@in.tum.de> �crivait (wrote):

> But this is not really flexible and more like a hack. Even in the manual
> of TikZ the issue arises, see manual version 2.0 on page 28. The
> rectangle shading from yellow to black has at the top side a black line
> which stands out because the yellow part starts there, too.
>
> Is there some convenient/elegant solution outside?

Don't use evince as pdf viewer...

--
Paul Gaborit - <http://perso.mines-albi.fr/~gaborit/>

Stefan Schulze Frielinghaus

unread,
May 7, 2010, 1:09:37 PM5/7/10
to
On Fr, 2010-05-07 at 17:53 +0200, Paul Gaborit wrote:
[...]

> Don't use evince as pdf viewer...

I expected a lot of things but that my PDF viewer is the root of evil I
didn't ;-)

After a quick test, Xpdf displays both PDF files correctly. Thanks for
your hint!

Regards,
Stefan

0 new messages