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 have a slide with a figure in it. I want to draw a rounded corner rectangle overtop part of a figure to highlight that section. Bonus points if you can draw two rounded rectangles as overlays that appear one at a time.

alt text

\documentclass{beamer}
\usepackage[T1]{fontenc}

\begin{document}

\begin{frame}
    \frametitle{ESR1} 

    \begin{center}
        Functional analysis
    \end{center}

    \begin{center}
        \includegraphics[width=1\textheight]{some_image.jpg}
    \end{center}
\end{frame}
\end{document}

(Note: I removed most of the unnecessary code in the example code, so the theme in the picture doesn't match with the default one in the example code anymore. --Caramdir)

share|improve this question
1  
What can I get for all those bonus points? ;-) –  Caramdir Jan 13 '11 at 19:49
    
Bonus kharma of course –  denilw Jan 13 '11 at 21:07
    
I shortened your example a little bit, I hope that is fine. –  Caramdir Jan 13 '11 at 21:57
    
Yes, thank you. –  denilw Jan 13 '11 at 22:13
add comment

3 Answers

up vote 22 down vote accepted

You can include the picture into a TikZ node and then draw some rectangles over it. For example,

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}

\begin{frame}
    \frametitle{ESR1} 

    \begin{center}
        Functional analysis
    \end{center}

    \begin{center}
        \begin{tikzpicture}
            \node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=1\textheight]{some_image.jpg}};
            \draw<1>[red,ultra thick,rounded corners] (1.6,1) rectangle (\textheight-1cm,5);
            \draw<2>[red,ultra thick,rounded corners] (5.7,4.1) rectangle (7.5,4.9);
        \end{tikzpicture}
    \end{center}
\end{frame}
\end{document}

with a picture from Wikipedia as some_image.jpg gives the two slides

example

Note the \node[anchor=south west,inner sep=0] at (0,0) {\includegraphics{...}}; line. This adds the picture so that the lower left corner is at the origin of the TikZ coordinate system. Section 14.6 “Rounding Corners” of the TikZ manual (v2.10) tells you how you can change the corner rounding.

Btw, do you really mean width=1\textheight?

share|improve this answer
    
Accepted fastest solution. Testing now. –  denilw Jan 13 '11 at 23:00
    
I think the text's height is the limiting factor for this image when the title is taken into account. I may be wrong, maybe that command doesn't even consider the title. –  denilw Jan 13 '11 at 23:03
    
width=1\textheight sets the width of the picture to the height of the text. –  Caramdir Jan 13 '11 at 23:09
1  
@denilw, you should test before accepting... –  Caramdir Jan 13 '11 at 23:10
add comment

Damn you Caramdir, four minutes too late!

Anyway, here's what I came up with. Caramdir's is at least as good, but mine is a bit closer to your syntax, maybe...

\documentclass[english,ignorenonframetext,table]{beamer}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{graphicx}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
%% A simple dot to overcome graphicx limitations
\newcommand{\lyxdot}{.}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
 % this default might be overridden by plain title style
 \newcommand\makebeamertitle{\frame{\maketitle}}%
 \AtBeginDocument{
   \let\origtableofcontents=\tableofcontents
   \def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
   \def\gobbletableofcontents#1{\origtableofcontents}
 }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{xcolor}
\usepackage{listings}
\usetheme{Frankfurt} %Warsaw
\usecolortheme{albatross}
\setbeamercovered{transparent}

\newcommand{\tformating}{
 \definecolor{darkPurple}{rgb}{0.101960784313725,0,0.2}
 \definecolor{purple}{rgb}{0.2,0,0.4}
 \definecolor{lightPurple}{rgb}{0.4,0,0.4}
 \rowcolors[]{1}{darkPurple}{purple}
 \small
}

\usepackage{tikz,overpic}
\usetikzlibrary{fit,shapes.misc}

\makeatother

\usepackage{babel}

\begin{document}
\begin{frame}

\frametitle{ESR1} 

\begin{center}
Functional analysis
\par\end{center}

\begin{center}
\only<1>{\begin{overpic}[width=1\textheight]{some_image.jpg}
\end{overpic}}%
\only<2>{\begin{overpic}[width=1\textheight]{some_image.jpg}
\put(40,38){\tikz \draw[red,thick,rounded corners] (0,0) rectangle (5,1.2);}
\end{overpic}}%
\only<3>{\begin{overpic}[width=1\textheight]{some_image.jpg}
\put(40,38){\tikz \draw[red,thick,rounded corners] (0,0) rectangle (5,1.2);}
\put(0,14){\tikz \draw[red,thick,rounded corners] (0,0) rectangle (3.5,1.2);}
\end{overpic}}%
\par\end{center}

\end{frame}
\end{document}

alt text

share|improve this answer
    
Some of my code came from your earlier code, which was changed. Grr! ;) –  frabjous Jan 13 '11 at 22:22
    
But you have an animated gif! –  Caramdir Jan 13 '11 at 22:25
1  
Yep. Does that get me any bonus points? –  frabjous Jan 13 '11 at 22:28
1  
I'm very impressed by the animated gif. Bonus kharma and +1 for you. –  denilw Jan 13 '11 at 23:00
    
Solution works. –  denilw Jan 13 '11 at 23:52
add comment

NOTES

Because I use PSTricks, the image is in eps format. My compilation steps are

  1. latex.exe to convert .tex to .dvi.
  2. dvips.exe to convert .dvi to .ps.
  3. ps2pdf.exe to convert .ps to .pdf.

alt text

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{pstricks}


\newdimen\ImageW
\ImageW=8cm

\newdimen\ImageH
\ImageH=6cm

\begin{document}

\begin{frame}[t]{ESR1} 

    \begin{center}
        Functional analysis
    \end{center}

    \begin{center}
        \pspicture(\ImageW,\ImageH)
        \rput(0.5\ImageW,0.5\ImageH){\includegraphics[width=\ImageW]{pitfall}}
        %\psgrid%turn on or off for navigational purpose during development
        \pause
        \psset{linecolor=red,linewidth=2pt,framearc=0.5}
        \psframe(5.2,3.8)(6.4,5.6)\pause
        \psframe(2.7,0)(4.5,1)       
        \endpspicture
    \end{center}

\end{frame}
\end{document}
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.