如何在框架中间创建像框架标题和框架子标题这样的框?

如何在框架中间创建像框架标题和框架子标题这样的框?

我正在准备讲义beamer。我想在框架中间制作标题,看起来像frametitleframesubtitle框。在下面的 MWE 中,我使用来block创建它,但我希望块主体为空。我该如何实现这一点?

\documentclass[aspectratio=169,10pt, notheorems]{beamer}
\usefonttheme{serif}
\usetheme{CambridgeUS}
\usepackage{xcolor}
\setbeamercolor{background canvas}{bg=black}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{structure}{fg=magenta}
\setbeamercolor{structure}{bg=black}

\begin{document}
    \begin{frame}{Frame title}{Frame subtitle}
        Proof of a theorem ends here. Title heading for the next section should appear in the following box.
        \begin{block}{This box should look like frame title box}
        \end{block}
        Title heading for the next subsection should appear in the following box.
        \begin{block}{This box should look like frame subtitle box}
        \end{block}
    \end{frame}
\end{document}

附言:这个答案没有帮助。

答案1

您可以通过搜索模板定义的位置来查找定义frametitle。对于主题CambridgeUS,您将找到它使用的内容beamerouterthemedefault.sty,因此您可以从那里借用其定义beamercolorbox,并删除仅用于框架标题特殊用途的所有内容。然后,您可以轻松地在 MWE 中使用它,如下所示:

\documentclass[aspectratio=169,10pt, notheorems]{beamer}
\usefonttheme{serif}
\usetheme{CambridgeUS}
\usepackage{xcolor}
\setbeamercolor{background canvas}{bg=black}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{structure}{fg=magenta}
\setbeamercolor{structure}{bg=black}

\begin{document}
\begin{frame}{Frame title}{Frame subtitle}
    Proof of a theorem ends here. Title heading for the next section should appear in the following box.

\begin{beamercolorbox}[sep=0.3cm,left,wd=\textwidth]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \strut This box should look like frame title box \strut\par%
    {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}This box should look like frame subtitle box\strut\par}%
    \vskip-1ex%
\end{beamercolorbox}%
\end{frame}
\end{document}

结果是:

在此处输入图片描述


如果您想要一个与纸张等宽的框,并将文本分成两部分,请执行以下操作:

\documentclass[aspectratio=169,10pt, notheorems]{beamer}
\usefonttheme{serif}
\usetheme{CambridgeUS}
\usepackage{xcolor}
\setbeamercolor{background canvas}{bg=black}
\setbeamercolor{normal text}{fg=white}
\setbeamercolor{structure}{fg=magenta}
\setbeamercolor{structure}{bg=black}

\begin{document}
\begin{frame}{Frame title}{Frame subtitle}
    Proof of a theorem ends here. Title heading for the next section should appear in the following box.

\begin{beamercolorbox}[sep=0.3cm,left,wd=\paperwidth]{frametitle}
    \usebeamerfont{frametitle}%
    \vbox{}\vskip-1ex%
    \strut This box should look like frame title box \strut\par%
    \vskip-1ex%
\end{beamercolorbox}%

\begin{beamercolorbox}[sep=0.3cm,left,wd=\paperwidth]{frametitle}
    {\usebeamerfont{framesubtitle}\usebeamercolor[fg]{framesubtitle}This box should look like frame subtitle box\strut\par}%
    \vskip-1ex%
\end{beamercolorbox}%
\end{frame}
\end{document}

相关内容