3

I had already a similar question. I know now how to color fade rectangles. But I was trying now for almost an hour and I couldn't figure out how to do a fading for a line.

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]

\draw[line width=4pt,orange] 
  ([yshift=-62pt]current page.north west) -- +(14cm,0pt);
\draw[orange,line width=1pt] 
  ([yshift=-175pt,xshift=+14cm]current page.north west) -- +(5.1cm,0pt);


\end{tikzpicture}
\end{document}

I want the lines to fade from left orange to right white.

3
  • A line can be be considered as a very thin rectangle... Dec 8, 2014 at 22:29
  • @PaulGaborit of course I tried that, but it seems there is a minimum width for a rectangle. At least I couldn't get it as thin as I wanted Dec 8, 2014 at 22:35
  • I meant miminum height Dec 8, 2014 at 22:47

1 Answer 1

6

A line can be be considered as a very thin rectangle...

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[remember picture,overlay]
\path[left color=orange,right color=white]
([yshift=-62pt]current page.north west)
+(0,-2pt) rectangle +(14cm,2pt); 

\path[left color=orange,right color=white]
([yshift=-175pt,xshift=+14cm]current page.north west)
+(0,-.5pt) rectangle +(5.1cm,0.5pt);
\end{tikzpicture}
\end{document}
4
  • my apologies, I did it with a \node don't know if that was the reason why it wasn't working Dec 8, 2014 at 23:22
  • 1
    @AdrianPfeifle A node uses implicitly inner sep distance (initially .3333em). If you want to use a node, try it with inner sep=0. Dec 8, 2014 at 23:26
  • 1
    thanks for the hint, now what I tried before is also working Dec 8, 2014 at 23:28
  • Hey Paul, any ideas how to integrate your MWE with the one here tex.stackexchange.com/questions/376873/… ? Jun 26, 2017 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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