![如何在框架中间创建像框架标题和框架子标题这样的框?](https://linux22.com/image/419859/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%A1%86%E6%9E%B6%E4%B8%AD%E9%97%B4%E5%88%9B%E5%BB%BA%E5%83%8F%E6%A1%86%E6%9E%B6%E6%A0%87%E9%A2%98%E5%92%8C%E6%A1%86%E6%9E%B6%E5%AD%90%E6%A0%87%E9%A2%98%E8%BF%99%E6%A0%B7%E7%9A%84%E6%A1%86%EF%BC%9F.png)
我正在准备讲义beamer
。我想在框架中间制作标题,看起来像frametitle
或framesubtitle
框。在下面的 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}