为什么投影仪列中的子项间距更宽?

为什么投影仪列中的子项间距更宽?

不等间距子项目

如图所示,列内的子子项在垂直方向上的间距明显大于列外的子子项。为了便于识别,我将项目符号替换为深度数字,因此可以清楚地看到它们处于同一级别。以下是代码。

\documentclass{beamer}
\setbeamertemplate{itemize item}{(1)}
\setbeamertemplate{itemize subitem}{(2)}
\setbeamertemplate{itemize subsubitem}{(3)}
\begin{document}
\begin{frame}
  \begin{itemize}
    \item a top item
      \begin{itemize}
        \begin{columns}
          \begin{column}{.5\linewidth}
            \item a sub item
              \begin{itemize}
                \item deep subbed item a
                \item deep subbed item b
                \item deep subbed item c
              \end{itemize}
            \item another sub item
          \end{column}
          \begin{column}{.5\linewidth}
            \item another column
          \end{column}
        \end{columns}
      \end{itemize}
  \end{itemize}
  \begin{itemize}
    \item items outside columns
      \begin{itemize}
        \item sub items outside columns
          \begin{itemize}
            \item deep subbed item d
            \item deep subbed item e
            \item deep subbed item f
          \end{itemize}
      \end{itemize}
  \end{itemize}
\end{frame}
\end{document}

什么原因导致列环境中的间距被修改以及如何纠正?

答案1

Acolumn本质上就是 a ,它们启动时所做的minipage事情之一minipage就是重置列表深度;它们实际上是为您尝试嵌套它们的方式而设计的。

在普通文档中,您可以通过简单地更改\@listdepth适当封装的内容来重置列表深度,如下所示\makeatletter / \makeatother

小型页面输出示例

\documentclass{article}

\begin{document}

\begin{itemize}
\item a top item
  \begin{itemize}
    \begin{minipage}{.8\linewidth}
    \item a sub item
      \begin{itemize}
      \item deep subbed item a wrongly spaced
      \item deep subbed item b
      \item deep subbed item c
      \end{itemize}
    \item another sub item
    \end{minipage}
  \end{itemize}
\end{itemize}

\begin{itemize}
\item a top item
  \begin{itemize}
    \begin{minipage}{.8\linewidth}\makeatletter\@listdepth2\makeatother
    \item a sub item 
      \begin{itemize}
      \item deep subbed item a correctly space
      \item deep subbed item b
      \item deep subbed item c
      \end{itemize}
    \item another sub item
    \end{minipage}
  \end{itemize}
\end{itemize}

\begin{itemize}
\item a top item
  \begin{itemize}
    \item a sub item 
      \begin{itemize}
      \item deep subbed item a no minipage
      \item deep subbed item b
      \item deep subbed item c
      \end{itemize}
    \item another sub item
  \end{itemize}
\end{itemize}

\end{document}

如果不添加选项beamer,则无法更改 catcodes 。通常这是不可取的,因此最好定义一个新命令来执行设置:framefragile\@listdepth

投影仪输出样本

\documentclass{beamer}
\setbeamertemplate{itemize item}{(1)}
\setbeamertemplate{itemize subitem}{(2)}
\setbeamertemplate{itemize subsubitem}{(3)}

\makeatletter
\newcommand{\setlistdepth}[1]{\expandafter\@listdepth#1}
\makeatother

\begin{document}
\begin{frame}
  \begin{itemize}
    \item a top item
      \begin{itemize}
        \begin{columns}
          \begin{column}{.5\linewidth}
            \item a sub item\setlistdepth{2}
              \begin{itemize}
                \item deep subbed item a
                \item deep subbed item b
                \item deep subbed item c
              \end{itemize}
            \item another sub item
          \end{column}
          \begin{column}{.5\linewidth}
            \item another column
          \end{column}
        \end{columns}
      \end{itemize}
  \end{itemize}
  \begin{itemize}
    \item items outside columns
      \begin{itemize}
        \item sub items outside columns
          \begin{itemize}
            \item deep subbed item d
            \item deep subbed item e
            \item deep subbed item f
          \end{itemize}
      \end{itemize}
  \end{itemize}
\end{frame}
\end{document}

顺便说一下,bemear它会为您提供预期的标签,因为它会跟踪带有\@itemdepth和不带有 的标签\@listdepth

答案2

当您添加 时column,它会与页面的中心对齐,而不是itemize

您需要手动更改列位置和 vspace。

我在左侧添加一列(并调整宽度)并修改 vspace:

带有新列和 vspace

\documentclass{beamer}
\setbeamertemplate{itemize item}{(1)}
\setbeamertemplate{itemize subitem}{(2)}
\setbeamertemplate{itemize subsubitem}{(3)}

\begin{document}
\begin{frame}
  \begin{itemize}
  { %%% to vspace affect only inside this block
    \item a top item
      \begin{itemize}

      \vspace{-3pt}

      \setbeamertemplate{itemize/enumerate subsubbody begin}{\vspace{-2pt}}
      \setbeamertemplate{itemize/enumerate subsubbody end}{\vspace{-2pt}}

      \newlength{\wideitemsep}
      \setlength{\wideitemsep}{\itemsep}
      \addtolength{\wideitemsep}{-2pt}
      \let\olditem\item
      \renewcommand{\item}{\setlength{\itemsep}{\wideitemsep}\olditem}

      \begin{columns}
        \begin{column}{.083\linewidth}
        \end{column}
        \begin{column}{.417\linewidth}
          \item a sub item
            \begin{itemize}
              \item deep subbed item a
              \item deep subbed item b
              \item deep subbed item c
            \end{itemize}
          \item another sub item
        \end{column}
        \begin{column}{.5\linewidth}
          \item another column
        \end{column}
      \end{columns}
    \end{itemize}
  }
  \end{itemize}
  \begin{itemize}
    \item items outside columns
      \begin{itemize}
        \item sub items outside columns
          \begin{itemize}
            \item deep subbed item d
            \item deep subbed item e
            \item deep subbed item f
          \end{itemize}
      \end{itemize}
  \end{itemize}
\end{frame}
\end{document}

相关内容