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.

When using the framezoom command, while centering the image;\

\documentclass{beamer}

\mode<presentation>{\usetheme{Warsaw}}

\begin{document}

\begin{frame}

\begin{center}

\framezoom<2><3>[border](3.5cm, 1.5cm)(1cm, 1cm)

\pgfimage[height=5cm]{example-image}

\end{center}

\end{frame}

\end{document}

The image will be centered and the border will be positioned as if the center is 0. But the zoom actually zooms on the part of the picture as if 0 is at the left of your slide.

So in short the border and zoom no longer match. My question is: Can i use framezoom with a border while centering my image

share|improve this question
    
Welcome to TeX.sx! Please always add a full, compilable but minimal working example (MWE) that illustrates your problem, not just code snippets. This way people can directly compile the code and test their solutions. I would also recommend to replace your image name with example-image so it can be easily compiled by other people who have the mwe bundle installed. –  Martin Scharrer May 10 '12 at 14:59

2 Answers 2

up vote 9 down vote accepted

This seems to be a bug of beamer IMHO. The \framezoom might use some form of anchor which is affected by the centering.

One way to solve this is the place the \framezoom outside of the center environment:

\documentclass{beamer}
\usetheme{Warsaw}

\begin{document}

\begin{frame}
\framezoom<2><3>[border](3.5cm, 1.5cm)(1cm, 1cm)
\begin{center}
\pgfimage[height=5cm]{example-image}
\end{center}

\end{frame}

\end{document}

Note that you can center images very easily using my adjustbox package if you use the export option and \includegraphics. \pgfimage is using \includegraphics for PDF output anyway AFAIK.

\documentclass{beamer}
\usetheme{Warsaw}
\usepackage[export]{adjustbox}
\begin{document}

\begin{frame}
\framezoom<2><3>[border](3.5cm, 1.5cm)(1cm, 1cm)
\includegraphics[height=5cm,center]{example-image}
\end{frame}

\end{document}
share|improve this answer
    
perfect that fixed it, should have thought of that myself. Thanks alot –  Rick de Groot May 10 '12 at 15:50

Martin Scharrer already gave good workarounds for this problem, so I want to fill in some information on why this happens:

The relevant code for \framezoom can be found in beamerbaseframesize.sty, ll. 39-135:

\def\beamer@framezoom<#1><#2>[#3](#4,#5)(#6,#7){%
  % [...]
  \only<#1>{%
    {\hypersetup{pdfhighlight={/P},pdfborder={0 0 \beamer@zoomborderwidth}}%
    \global\setbox\@tempboxa=\vbox{\hyperlink{\beamer@labelzoomed}{\vbox to #7{\hbox
          to#6{\hfil}\vfil}}}}%
    \ht\@tempboxa=0pt%
    \wd\@tempboxa=0pt%
    \dp\@tempboxa=0pt%
    \setbox\@tempboxa=\vbox{\moveright#4\hbox{\lower#5\vbox{\box\@tempboxa}}}%
    \ht\@tempboxa=0pt%
    \wd\@tempboxa=0pt%
    \dp\@tempboxa=0pt%
    \global\setbox\beamer@zoombox=\vbox to0pt{\unvbox\beamer@zoombox\box\@tempboxa}%
  }%
  % [...]
}

The above code snippet produces the clickable zoom frame and stores it in the box \beamer@zoombox, which is later inserted at the beginning of the frame (in beamerbaseframe.sty, l. 144). So generally it shouldn't be a problem to use \framezoom anywhere in your frame, as the reference point is always the beginning of the frame text.

However, in your example, this is apparently not true. The reason is that you use \framezoom in a center environment, which changes the paragraph margins using \leftskip and \rightskip. This messes up with the line

\global\setbox\@tempboxa=\vbox{\hyperlink{\beamer@labelzoomed}{\vbox to #7{\hbox
      to#6{\hfil}\vfil}}}}%

in the above code: As the margin changes are in effect, \hyperlink is centered inside the \vbox, with the consequence of a wrong placement of the zoom frame. To overcome this, you have to enclose the link in another \hbox, like this:

\global\setbox\@tempboxa=\vbox{\hbox{\hyperlink{\beamer@labelzoomed}{\vbox to #7{\hbox
      to#6{\hfil}\vfil}}}}}%

This can be done using \patchcmd from the etoolbox package:

\documentclass{beamer}
\usetheme{Warsaw}

\usepackage{etoolbox}
\makeatletter
  \patchcmd{\beamer@framezoom}{\hyperlink{\beamer@labelzoomed}{\vbox to #7{\hbox to#6{\hfil}\vfil}}}{\hbox{\hyperlink{\beamer@labelzoomed}{\vbox to #7{\hbox to#6{\hfil}\vfil}}}}{}{}
\makeatother

\begin{document}

\begin{frame}
\begin{center}
  \framezoom<2><3>[border](3.5cm, 1.5cm)(1cm, 1cm)
  \pgfimage[height=5cm]{example-image}
\end{center}
\end{frame}

\end{document}

However, there may still be exotic paragraph parameters where this workaround will also fail. So maybe it's best to stick to the advice given in the beamer manual:

This command [i.e. \framezoom] should be given somewhere at the beginning of a frame.

share|improve this answer
    
+1 It's always nice to look up the reason of these issues. I didn't had time to do it myself. –  Martin Scharrer May 10 '12 at 22:09

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.