Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alterning images in beamer is shifting to right

When I am trying to do alternating images in beamer with usage of the \only and overlayarea like this:

\begin{frame}
    \frametitle{Tasks}

    \begin{overlayarea}{\textwidth}{\textheight}
        \begin{figure}
            \centering
            \only<1>
                {
                    \includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
                }
            \only<2>
                {
                    \includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
                }
            \only<3>
                {
                    \includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
                }
            \only<4>
                {
                    \includegraphics[width=0.3\textwidth]{img/noise_detail_2.png}
                }
        \end{figure}
    \end{overlayarea}      
\end{frame}

the image is moving to the right more and more on the each slide. Let's say, that in the 1. slide is in the position x, in the second slide in the position x+5 and in the third slide x+10.

Why? How can I fix it?

like image 608
tucna Avatar asked Oct 03 '14 20:10

tucna


People also ask

How to set image in center in LaTeX?

Centering. We center text or images using \begin{center} and \end{center}. Just put \begin{center} when you want to start centering, and \end{center} when you want to stop centering.

How do I change the aspect ratio on my Beamer?

LyX, beamer and aspect ratio Topic is solved AFAIR at "Document→Settings→Document Class" you can set custom options to the class. For 16:9 use option aspectratio=169 .

How to resize images in overleaf?

Changing the image size and rotating the pictureThe command \includegraphics[scale=1.5]{overleaf-logo} will include the image overleaf-logo in the document, the extra parameter scale=1.5 will do exactly that, scale the image 1.5 of its real size. You can also scale the image to a some specific width and height.

How to include a photo in LaTeX?

Including images in your LaTeX document requires adding: \usepackage{graphicx} to the beginning/preamble of your document. \includegraphics{ } command tells LaTeX to insert the image. To upload an image, click the upload button, and upload your image file.


1 Answers

You have what is referred to as a spurious space between usages of \only. While spreading out your code for readability purposes might work well, sometimes these spaces cause unwanted output in your resulting PDF. Use % to keep the readability but avoid the spacing issues:

enter image description here

\documentclass{beamer}
\begin{document}

\begin{frame}
  \frametitle{Tasks}

  \begin{overlayarea}{\textwidth}{\textheight}
    \begin{figure}
      \centering
      \only<1>
        {%
          \includegraphics[width=.8\textwidth]{example-image-a}%
        }%
      \only<2>
        {%
          \includegraphics[width=.8\textwidth]{example-image-b}%
        }%
      \only<3>
        {%
          \includegraphics[width=.8\textwidth]{example-image-c}%
        }%
    \end{figure}
  \end{overlayarea}      
\end{frame}

\end{document}
like image 192
Werner Avatar answered Sep 26 '22 21:09

Werner