投影仪中的交替图像向右移动

时间:2014-10-03 20:30:27

标签: image latex beamer

当我尝试使用 \ only overlayarea 时,使用beamer中的交替图像:

\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}

图像在每张幻灯片上越来越向右移动。假设,1.幻灯片位于 x 位置,第二张幻灯片位于 x + 5 位置,第三张幻灯片 x + 10

为什么呢?我该如何解决?

1 个答案:

答案 0 :(得分:11)

\only的用法之间,你有一个被称为虚假空间的东西。虽然为了可读性而扩展代码可能效果很好,但有时这些空间会在生成的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}