为什么 \setbeamerfont{}{} 命令在我的 beamer 演示文稿的标题中不起作用?

为什么 \setbeamerfont{}{} 命令在我的 beamer 演示文稿的标题中不起作用?

我正在尝试增加演示文稿标题中节和子节的字体大小和粗细。但是,该命令似乎\setbeamerfont{section in head/foot}{series=\bfseries,size=\normalsize}不起作用。可能的原因是什么?

平均能量损失

\documentclass{beamer}

% loading packages
\usepackage{fontspec}

% Removing Navigation Icon
\setbeamertemplate{navigation symbols}{}

%customizing headline
\setbeamertemplate{headline}
{%
\leavevmode %\bfseries\normalsize % this wrok just fine, however \setbeamerfont command does not seem to do anything. 
\begin{beamercolorbox}[wd=0.5\paperwidth, ht=10pt, dp=5pt, center]{section in head/foot}
    \insertsectionhead
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=0.5\paperwidth, ht=10pt, dp=5pt, center]{subsection in head/foot}
    \insertsubsectionhead
\end{beamercolorbox}
}
\setbeamercolor{section in head/foot}{bg=black!30, fg=black}
\setbeamercolor{subsection in head/foot}{bg=red!30, fg=black}
\setbeamerfont{section in head/foot}{series=\bfseries,size=\normalsize} % this command is not working
\setbeamerfont{subsection in head/foot}{series=\bfseries, size=\normalsize} % this command is not working

\begin{document}
    % first page (Title Page) costomization
    \title{Main Title Here}
    \subtitle{Subtitle Here}
    \author{Author}
    \institute{Institute Name}
    \date{\today}
    \begin{frame}[noframenumbering, plain]
        \titlepage
    \end{frame}
    %
    % Adding table of contents
    \begin{frame}[noframenumbering, plain]
        \tableofcontents
    \end{frame}
    %
    \section{Section 1}
    \subsection{Subsection 1.A}
    \begin{frame}{How blocks are defined}
        \begin{block}{Block}
            This was created using block environment.
        \end{block}
        \begin{alertblock}{Alertblock}
            This was created using alertblock environment.
        \end{alertblock}
        \begin{definition}
            This was created using definition environment.
        \end{definition}
        \begin{example}
            This was created using example environment.
        \end{example}
    \end{frame}
    %
    \section{Section 2}
    \subsection{Subsection 2.A}
    \begin{frame}{How lists are defined}
        \begin{columns}
            \column{0.5\paperwidth}
            \begin{enumerate}
                \item item 1 of enumerate
                \item item 2 of enumerate
                \item item 3 of enumerate
                \item item 4 of enumerate
            \end{enumerate}
            \column{0.5\paperwidth}
            \begin{itemize}
                \item item 1 of itemize
                \item item 2 of itemize
                \item item 3 of itemize 
                \item item 4 of itemize
            \end{itemize}
        \end{columns}
    \end{frame}
\end{document}

我得到的结果 图片 1

我想要的结果 在此处输入图片描述

答案1

(sub-)section in head/foot重新定义标题时,您需要实际使用字体:

\documentclass{beamer}

% loading packages
\usepackage{fontspec}

% Removing Navigation Icon
\setbeamertemplate{navigation symbols}{}

%customizing headline
\setbeamertemplate{headline}
{%
\leavevmode %\bfseries\normalsize % this wrok just fine, however \setbeamerfont command does not seem to do anything. 
\begin{beamercolorbox}[wd=0.5\paperwidth, ht=10pt, dp=5pt, center]{section in head/foot}
    \usebeamerfont{section in head/foot}%
    \insertsectionhead
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=0.5\paperwidth, ht=10pt, dp=5pt, center]{subsection in head/foot}
    \usebeamerfont{subsection in head/foot}
    \insertsubsectionhead
\end{beamercolorbox}
}
\setbeamercolor{section in head/foot}{bg=black!30, fg=black}
\setbeamercolor{subsection in head/foot}{bg=red!30, fg=black}
\setbeamerfont{section in head/foot}{series=\bfseries,size=\normalsize} % this command is not working
\setbeamerfont{subsection in head/foot}{series=\bfseries, size=\normalsize} % this command is not working

\begin{document}
    % first page (Title Page) costomization
    \title{Main Title Here}
    \subtitle{Subtitle Here}
    \author{Author}
    \institute{Institute Name}
    \date{\today}
    \begin{frame}[noframenumbering, plain]
        \titlepage
    \end{frame}
    %
    % Adding table of contents
    \begin{frame}[noframenumbering, plain]
        \tableofcontents
    \end{frame}
    %
    \section{Section 1}
    \subsection{Subsection 1.A}
    \begin{frame}{How blocks are defined}
        \begin{block}{Block}
            This was created using block environment.
        \end{block}
        \begin{alertblock}{Alertblock}
            This was created using alertblock environment.
        \end{alertblock}
        \begin{definition}
            This was created using definition environment.
        \end{definition}
        \begin{example}
            This was created using example environment.
        \end{example}
    \end{frame}
    %
    \section{Section 2}
    \subsection{Subsection 2.A}
    \begin{frame}{How lists are defined}
        \begin{columns}
            \column{0.5\paperwidth}
            \begin{enumerate}
                \item item 1 of enumerate
                \item item 2 of enumerate
                \item item 3 of enumerate
                \item item 4 of enumerate
            \end{enumerate}
            \column{0.5\paperwidth}
            \begin{itemize}
                \item item 1 of itemize
                \item item 2 of itemize
                \item item 3 of itemize 
                \item item 4 of itemize
            \end{itemize}
        \end{columns}
    \end{frame}
\end{document}

在此处输入图片描述

相关内容