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 writing a presentation in beamer. I have a background image that I have included with \setbeamertemplate{background canvas}{...}. Within a regular slide, I now would like to create a rectangle that fades from a color to fully transparent in Tikz. If I create a rectangle with fading, i.e. \tikz{\fill[left color=RED,right color=transparent] (0,0) rectangle (\linewidth,1.5em);} It creates the rectangle, but rather than being see-through at the right end, it is black.

Is there a way to define opacity in fade, such that the background image becomes visible?

M.W.E

\documentclass{beamer}
  \usepackage{tikz}
  \usepackage{graphicx}
  \usetikzlibrary{shapes.arrows, fadings}

  \setbeamertemplate{background canvas}{\includegraphics[width=\paperwidth]{picture.jpg}}

  \begin{document}
    \begin{frame}
      \tikz{\fill[left color=red,right color=transparent] (0,0) rectangle (\linewidth,1.5em);}
    \end{frame}
  \end{document}

(Use any random picture for the background)

share|improve this question

1 Answer 1

up vote 7 down vote accepted

You need to set up a fading via \tikzfading and then use the fade path option to the fill command:

Sample output

\documentclass{beamer}
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{shapes.arrows, fadings}

\setbeamertemplate{background canvas}{\includegraphics[width=\paperwidth]{example-image-a.jpg}}

\tikzfading[name=fade right,
  left color=transparent!0, right color=transparent!100]

\begin{document}
\begin{frame}
  \tikz{\fill[red,path fading=fade right] (0,0) rectangle (\linewidth,1.5em);}
\end{frame}
\end{document}

See section 20.3.1 Creating Fadings of the pgfmanual.

share|improve this answer

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.