![如何在 beamer 模板中并排放置章节/小节标题](https://linux22.com/image/441663/%E5%A6%82%E4%BD%95%E5%9C%A8%20beamer%20%E6%A8%A1%E6%9D%BF%E4%B8%AD%E5%B9%B6%E6%8E%92%E6%94%BE%E7%BD%AE%E7%AB%A0%E8%8A%82%2F%E5%B0%8F%E8%8A%82%E6%A0%87%E9%A2%98.png)
现在我正在使用
\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}