Beamer:使用 \only 纠正垂直对齐

Beamer:使用 \only 纠正垂直对齐

我就直接说重点吧。MWE:

\documentclass{beamer}
\usetheme{metropolis}

\begin{document}

\begin{frame}[t]{title}
\begin{itemize}
    \item 0
    \only<+>{
        \item a
    }
    \only<+>{
        \item b
        \item c
    }
    \only<+>{
        \item d
        \item e
        \item f
        \item 
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
    }
\end{itemize}
\end{frame}
\end{document}

即 0 始终停留在顶部,a 在第一张幻灯片上然后离开,b 和 c 在第二张幻灯片上出现并离开,依此类推。

问题是,dg 非常长,因此在第三张幻灯片上,项目 0 稍微浮动到顶部(小于 0.5em)。但是,幻灯片底部仍有足够的空间来避免这种情况发生。框架选项 [t] 似乎没有帮助。这非常令人恼火,因为第三张幻灯片乍一看似乎完全是新奇的东西。

我相信这个问题很容易解决。我很感激任何帮助。非常感谢!

答案1

您可以通过将整个项目包装在一个overlay高度足够容纳长文本项目的区域中来解决此问题:

\documentclass{beamer}
\usetheme{moloch}% modern fork of the metropolis theme

\begin{document}

\begin{frame}[t]{title}
\begin{overlayarea}{\textwidth}{.86\textheight}
\begin{itemize}
    \item 0
    \only<+>{%
        \item a
    }
    \only<+>{%
        \item b
        \item c
    }
    \only<+>{%
        \item d
        \item e
        \item f
        \item 
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
        ggggggggggggggggggggggggggggggggggggggggg
    }
\end{itemize}
\end{overlayarea}
\end{frame}
\end{document}

enter image description here

相关内容