如何在框架中間創建像frametitle和framesubtitle這樣的框?

如何在框架中間創建像frametitle和framesubtitle這樣的框?

我正在準備一個講稿beamer。我想在框架中間製作標題,它應該看起來像frametitleframesubtitle盒子。在下面的 MWE 中,我使用 ablock來創建它,但我希望塊體為空。我該如何實現這個目標?

\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}

相關內容