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 wonder whether it is possible to create a transparent shading effect (like the one below) without an exact specification of the fill color. This solution is good until I have to change the background to a non-solid fill (demonstrated by the yellow block). Can I create the (almost, I want to see the yellow line) same effect somehow with a transparent shade?

(Sorry for the brutal yellow, it is for demonstration purposes only.)

enter image description here

\documentclass{article}
\usepackage{tikz}

\begin{document}
\parindent0pt
  \null
  \definecolor{orange}{RGB}{233,77,16}

  \thispagestyle{empty}
  \vspace{-1cm}
  \vfill
  \hfil
  \begin{tikzpicture}[overlay]
    \coordinate (gNE)                       at (+0.501\paperwidth,+0.501\paperheight);
    \coordinate (gSW)                       at (-0.501\paperwidth,-0.501\paperheight);
    \coordinate (titleN)                at (+0.000\paperwidth,+0.300\paperheight);
    \coordinate (titleS)                at (+0.000\paperwidth,+0.100\paperheight);

    \fill [color=orange] (gSW) rectangle (gNE);
    \fill [color=yellow] (0.3\paperwidth,0.51\paperheight) rectangle (0.4\paperwidth,-0.5\paperheight);
    \shade [left color=black, right color=orange] (titleS -| gSW) rectangle (titleN -| gNE);
  \end{tikzpicture}
  \vfill

\end{document}
share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

You can use path fading=east from the fadings library for this:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fadings}

\begin{document}
\parindent0pt
  \null
  \definecolor{orange}{RGB}{233,77,16}

  \thispagestyle{empty}
  \vspace{-1cm}
  \vfill
  \hfil
  \begin{tikzpicture}[overlay]
    \coordinate (gNE)                       at (+0.501\paperwidth,+0.501\paperheight);
    \coordinate (gSW)                       at (-0.501\paperwidth,-0.501\paperheight);
    \coordinate (titleN)                at (+0.000\paperwidth,+0.300\paperheight);
    \coordinate (titleS)                at (+0.000\paperwidth,+0.100\paperheight);

    \fill [color=orange] (gSW) rectangle (gNE);
    \fill [color=yellow] (0.3\paperwidth,0.51\paperheight) rectangle (0.4\paperwidth,-0.5\paperheight);
    \fill [black, path fading=east] (titleS -| gSW) rectangle (titleN -| gNE);
  \end{tikzpicture}
  \vfill

\end{document}
share|improve this answer
    
Thanks (+1). Although I have a different output with this code. A whitish tint is all-over the black fading box. Can it be caused by MikTeX? –  masu Dec 11 '13 at 8:52
    
@masu: That's probably an issue with the viewer. What viewer are you using? –  Jake Dec 11 '13 at 8:52
    
Hah, It was the reader... thank you. –  masu Dec 11 '13 at 8:56
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.