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'm making a beamer presentation and I'd like to first show an image in its true form:

fig

and in the next slide have it shown with a shadow over a part of it like so:

fig_w_shadow

Is there a way to do this?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

Here is a very robust way of doing it:

enter image description here

\documentclass{beamer}% http://ctan.org/pkg/beamer
\newsavebox{\myimage}
\savebox{\myimage}{\quad\fbox{\includegraphics[width=150pt]{tiger}}\quad}% Store image with padding
\begin{document}
\begin{frame}
  \frametitle{A frame title}
  \onslide<2>{%
    \smash{% Remove vertical height
      \rlap{% Right overLAP (zero-width, left-aligned)
        \color{black!30}% Background colour
          \rule[\dimexpr-\ht\myimage-\baselineskip]{\wd\myimage}{.5\ht\myimage}% Box
          }}}%
  \usebox{\myimage}
\end{frame}
\end{document}

The idea is to print a block (\rule[<depth>]{<width>}{<height>}) of specific colour (\color{black!30} = 30% black) in the background of the image (stored in a box \myimage) that has zero width (\rlap) and height (\smash) and position it properly to only highlight the area you're after. The padding is used in \myimage (a \quad or \hspace*{1em} on both sides).

The overlay specification \onslide<.> prints the block only on slide 2. You would have to play with the measurements, since I don't have your image/chart.

Note: This requires your image (or chart) to be transparent so the block can be visible where nothing is drawn.


If you're after the reverse, and using some transparency in an overlay, then the following might be what you're after. Similar techniques are followed, only using the transparent package's \transparent{<num>} to specify the transparency of the colour used (0 = fully transparent; 1 = fully opaque):

enter image description here

\documentclass{beamer}% http://ctan.org/pkg/beamer
\usepackage{transparent}% http://ctan.org/pkg/transparent
\newsavebox{\myimage}
\savebox{\myimage}{\quad\fbox{\includegraphics[width=150pt]{tiger}}\quad}% Store image with padding
\begin{document}
\begin{frame}
  \frametitle{A frame title}
  \rlap{\usebox{\myimage}}%
  \onslide<2>{%
    \smash{% Remove vertical height
      \color{black}\transparent{0.8}% Overlay colour = black + 80% opaque
        \rule{\wd\myimage}{.5\ht\myimage}% Box
    }}%
\end{frame}
\end{document}
share|improve this answer
    
This looks like the way to go but I notice in your picture the shadow is located behind the image (the tiger's face) when I actually want it up front. Can this be done? Thank you! –  Gabriel Mar 5 '13 at 21:10
    
@Gabriel: I placed it behind since that's what your example image/chart looks like. If you place it over top, you won't be able to see what's behind it. Is that what you're after? Or, perhaps, do you want some form of transparency? –  Werner Mar 5 '13 at 21:12
    
The difference between my example image and yours is that I want the "shadow" (grey block) to cover a section of the image in a transparent way so that I can still see the that part of the original image below it. In your example the original image is in the front and the "shadow" in the background, what I need is the other way around. –  Gabriel Mar 5 '13 at 21:14
    
@Gabriel: See my edit. –  Werner Mar 5 '13 at 21:32
    
Yessss! That's what I was looking for, thank you! At the risk of abusing your generosity here, is there a way to do this without having to define \myimage at the beginning? This way starts to get complicated when you try to use it with multiple figures (hence having to define each one separately in a box of its own). In any case your answer is what I was after so I'm accepting it. Cheers. –  Gabriel Mar 5 '13 at 21:41
add comment

There is the always present tikz solution.

You can put your image into a tikz node and then use the node anchors as reference points for the rectangular cover. I defined a macro to ease the repeated use. The first argument is the slide in which that cover will appear, the second argument is the amount lf the image to be covered (1 covers the full image, 0.5 only the bottom half, and so on). An example:

\documentclass{beamer}
\usepackage{tikz,graphicx}
\usetikzlibrary{calc}
\def\coverfig#1#2{
    \coordinate (zone) at ($(fig.south)!#2!(fig.north)$);
    \fill<#1>[black, opacity=0.3] (fig.south west) rectangle(fig.east|-zone);
}

\begin{document}
\begin{frame}
  \begin{center}
  \begin{tikzpicture}
    \node[inner sep=1em] (fig) {\includegraphics[width=0.6\linewidth]{tiger}};
    \coverfig{1}{.8}
    \coverfig{2}{.5}
    \coverfig{3}{.2}
  \end{tikzpicture}
\end{center}
\end{frame}
\end{document}

Results in:

animation

share|improve this answer
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.