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

tuc*_*cna 5 latex image beamer

当我试图在beamer中使用\ onlyoverlayarea这样的交替图像:

\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}
Run Code Online (Sandbox Code Playgroud)

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

为什么?我该如何解决?

Wer*_*ner 14

你有所谓的虚假空间\only.虽然为了可读性而扩展代码可能效果很好,但有时这些空间会在生成的PDF中导致不必要的输出.使用%以保持可读性,避免间距的问题:

在此输入图像描述

\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}
Run Code Online (Sandbox Code Playgroud)