如何在 beamer 模板中并排放置章节/小节标题

如何在 beamer 模板中并排放置章节/小节标题

现在我正在使用

\setbeamertemplate{headline}
    {%
      \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
      \end{beamercolorbox}
      \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
          leftskip=.3cm,rightskip=.3cm plus1fil]{section in head/foot}
        \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
        \insertsectionhead
      \end{beamercolorbox}%
      \begin{beamercolorbox}[colsep=1.5pt]{middle separation line head}
      \end{beamercolorbox}
      \begin{beamercolorbox}[ht=2ex,dp=1.125ex,%
        leftskip=.3cm,rightskip=.3cm plus1fil]{subsection in head/foot}
        \usebeamerfont{subsection in head/foot}\setbeamercolor{subsection in head/foot}{fg=blue}%
        \footnotesize\insertsubsectionhead
      \end{beamercolorbox}%
      \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
      \end{beamercolorbox}
    }

上述代码将章节/小节标题与达姆施塔特主题结合起来。

我想要的是将章节/小节标题并排放置。

我该怎么做呢?

在此处输入图片描述

答案1

如果你减小 s 的宽度beamercolorbox,你就可以将它们并排放置:

\documentclass{beamer}

\usetheme{CambridgeUS}

\makeatletter
\setbeamertemplate{headline}
    {%
      \begin{beamercolorbox}[colsep=1.5pt]{upper separation line head}
      \end{beamercolorbox}
      \hbox{%
      \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
          leftskip=.3cm,rightskip=.3cm plus1fil,wd=.5\paperwidth]{section in head/foot}
        \usebeamerfont{section in head/foot}\usebeamercolor[fg]{section in head/foot}%
        \insertsectionhead
      \end{beamercolorbox}%
      \begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
        leftskip=.3cm,rightskip=.3cm plus1fil,wd=.5\paperwidth]{subsection in head/foot}
        \usebeamerfont{subsection in head/foot}\setbeamercolor{subsection in head/foot}{fg=blue}%
        \insertsubsectionhead
      \end{beamercolorbox}}%
      \begin{beamercolorbox}[colsep=1.5pt]{lower separation line head}
      \end{beamercolorbox}
    }
\makeatother

\title{title}

\begin{document}
    
\section{section}
\subsection{subsection}  
\begin{frame}
\frametitle{frametitle}
    abc
\end{frame} 
    
\end{document}

相关内容