两列 Beamer ToC 对齐不良

两列 Beamer ToC 对齐不良

我正在尝试在 Beamer 中制作一个漂亮的两栏目录。关于它有很多问题,但我看不到有人真正回答我的问题。

使用multicol环境,拆分目录很容易。但是,即使条目数是偶数,目录内部对齐也很糟糕。我添加了代码

\makeatletter
\patchcmd{\beamer@sectionintoc}
  {\vfill}
  {\vskip1.5em}
  {}
  {}
\makeatother

添加更多空间,这也强调了不良对齐。

问题Beamer:多列 ToC 的垂直对齐解决了问题,但解决方案是手动的(提供目录中的哪些部分应该打印在哪一列)。我相信应该有某种方式来填充第一列所需的空间,以便两列的顶部保持平衡,但我不知道该怎么做。有什么想法吗?

在此处输入图片描述

梅威瑟:

\documentclass[xcolor=dvipsnames]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{multicol,etoolbox}

\usetheme{Boadilla}
\usecolortheme[named=OliveGreen]{structure}
\usefonttheme[stillsansseriflarge]{serif}

\AtBeginSection[]
{
  \begin{frame}{Innhold}{\hfill}
  \begin{columns}
    \column{.1\textwidth}
    \column{.8\textwidth}
   \begin{multicols}{2}
      \centering
      \tableofcontents[currentsection, sectionstyle=show/shaded,
  %subsectionstyle=show/show/hide
  ]
   \end{multicols}
    \column{.1\textwidth}
\end{columns}
  \end{frame}
}

\makeatletter
\patchcmd{\beamer@sectionintoc}
  {\vfill}
  {\vskip1.5em}
  {}
  {}
\makeatother

\begin{document}

\begin{frame}
  {Innhold}{}
  \begin{columns}
    \column{.1\textwidth}
    \column{.8\textwidth}
      \begin{multicols}{2}
        \tableofcontents
      \end{multicols}
    \column{.1\textwidth}
  \end{columns}
\end{frame}

\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}

\end{document}

答案1

在 中beamerbasetoc.sty\beamer@tableofcontents

\def\beamer@tableofcontents[#1]{%
  \def\beamer@toc@cs{show}%
  \def\beamer@toc@os{show}%
  \def\beamer@toc@css{show}%
  \def\beamer@toc@oss{show}%
  \def\beamer@toc@ooss{show}%
  \def\beamer@toc@csss{show}%
  \def\beamer@toc@osss{show}%
  \def\beamer@toc@oosss{show}%
  \def\beamer@toc@ooosss{show}%
  \beamer@showpartnumber=\c@part%
  \beamer@pausesectionsfalse%
  \beamer@pausesubsectionsfalse%
  \def\beamer@tocsections{<*>}%
  \setkeys{beamertoc}{firstsection=1}%
  \setkeys{beamertoc}{#1}%
  \vspace*{-.5em}{\makeatletter%
    \pause[0]%
    \@input{\jobname.toc}%
    \vfill}%
  }

\vspace*{-.5em}开头的那个不知怎么地压低了目录。所以就把它删掉吧。


我知道这有点令人惊讶。只要尝试一下,你就会看到结果。

粗略地说,multicols使每列的第一行至少1em高,即它的高度1em或更高。因此,当你说时\vspace*{-.5em},负空间本身就变成了第一行。所以你可以想象第一行有高度1em和深度-.5em。它确实是一个正空间,因此推动了内容向下

PS 从技术上讲,\vspaces(垂直空间)与水平盒子不同,没有高度和深度,它们已经是空间了。


平均能量损失

\documentclass[xcolor=dvipsnames]{beamer}

\usepackage[utf8]{inputenc}
\usepackage{multicol,etoolbox}

\usetheme{Boadilla}
\usecolortheme[named=OliveGreen]{structure}
\usefonttheme[stillsansseriflarge]{serif}

\AtBeginSection[]
{
  \begin{frame}{Innhold}{\hfill}
  \begin{columns}
    \column{.1\textwidth}
    \column{.8\textwidth}
   \begin{multicols}{2}
      \centering
      \tableofcontents[currentsection, sectionstyle=show/shaded,
  %subsectionstyle=show/show/hide
  ]
   \end{multicols}
    \column{.1\textwidth}
\end{columns}
  \end{frame}
}

\makeatletter
\def\beamer@tableofcontents[#1]{%
  \def\beamer@toc@cs{show}%
  \def\beamer@toc@os{show}%
  \def\beamer@toc@css{show}%
  \def\beamer@toc@oss{show}%
  \def\beamer@toc@ooss{show}%
  \def\beamer@toc@csss{show}%
  \def\beamer@toc@osss{show}%
  \def\beamer@toc@oosss{show}%
  \def\beamer@toc@ooosss{show}%
  \beamer@showpartnumber=\c@part%
  \beamer@pausesectionsfalse%
  \beamer@pausesubsectionsfalse%
  \def\beamer@tocsections{<*>}%
  \setkeys{beamertoc}{firstsection=1}%
  \setkeys{beamertoc}{#1}%
  %\vspace*{-.5em}
  {\makeatletter%
    \pause[0]%
    \@input{\jobname.toc}%
    \vfill}%
  }
\makeatother

\begin{document}

\begin{frame}
  {Innhold}{}
  \begin{columns}
    \column{.1\textwidth}
    \column{.8\textwidth}
      \begin{multicols}{2}
        \tableofcontents
      \end{multicols}
    \column{.1\textwidth}
  \end{columns}
\end{frame}

\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}
\section{This is a section}
\begin{frame}
  {}
  Some content
\end{frame}

\end{document}

相关内容