调整 Beamer 中枚举列表前的垂直空间

调整 Beamer 中枚举列表前的垂直空间

在 Beamer 中,我可以使用 轻松设置枚举列表中项目之间的所需垂直空间itemsep。但是,如何设置介绍枚举列表的行与此列表中的第一个项目之间的垂直空间?理想情况下,我希望它与列表中项目之间的空间相同。在下面的 MWE 中,我希望在逐项行“这里有两件有趣的事情:”之后有更多的空间

\documentclass{beamer}
\usepackage{lmodern}

\begin{document}
    \begin{frame}
        \begin{itemize}
            \item Here are two interesting things:
            \begin{enumerate} \itemsep2ex
                \item This is number one.
                \item And this is number two.
            \end{enumerate}
        \end{itemize}
    \end{frame}
\end{document}

在此处输入图片描述

答案1

在 beamer 情况下,简单地按通常方式设置\topsep不起作用。相反,您可以\@listii按如下方式重新定义:

样品输出

\documentclass{beamer}
\usepackage{lmodern}

\makeatletter
\def\@listii{\leftmargin\leftmarginii
              \topsep    2ex
              \parsep    0\p@   \@plus\p@
              \itemsep   \parsep}
\makeatother

\begin{document}
    \begin{frame}
        \begin{itemize}
            \item Here are two interesting things:
            \begin{enumerate} \itemsep2ex
                \item This is number one.
                \item And this is number two.
            \end{enumerate}
        \end{itemize}
    \end{frame}
\end{document}

beamerbaselocalstructure.sty请参阅包含格式变量的文件\@listi\@listii以及\@listiii分别用于深度一、二和三的列表的格式。

\topsep您可以定义宏,将 设置为给定级别列表的\itemsep相同值 ( #2),如下例所示。如果您希望将定义更改的范围限定在单个帧内,这将非常有用。

\documentclass{beamer}
\usepackage{lmodern}

\makeatletter
\newcommand{\setlistspacing}[2]{\def\@ld{#1}\expandafter\def\csname
@list\romannumeral\@ld \endcsname{\leftmargin\csname
leftmargin\romannumeral\@ld \endcsname
              \topsep    #2
              \parsep    0\p@   \@plus\p@
              \itemsep   #2}}
\makeatother

\begin{document}
{\setlistspacing{2}{2ex}
\begin{frame}
  \begin{itemize}
  \item Here are two interesting things:
    \begin{enumerate}
    \item This is number one.
    \item And this is number two.
    \end{enumerate}
  \item Here are no interesting things.
  \item Here are two interesting things:
    \begin{enumerate}
    \item This is number one.
    \item And this is number two.
    \end{enumerate}
  \end{itemize}
\end{frame}
}

{\setlistspacing{1}{4ex}
\begin{frame}
  \begin{itemize}
  \item Here are two interesting things:
    \begin{enumerate}
    \item This is number one.
    \item And this is number two.
    \end{enumerate}
  \item Here are no interesting things.
  \item Here are two interesting things.
    \begin{enumerate}
    \item This is number one.
    \item And this is number two.
    \end{enumerate}
  \end{itemize}
\end{frame}
}

\begin{frame}
  \begin{itemize}
  \item Here are two interesting things:
    \begin{enumerate}
    \item This is number one.
    \item And this is number two.
    \end{enumerate}
  \end{itemize}
\end{frame}

\end{document

}

示例输出

相关内容