为什么这个 Beamer 普通选项仅在它不是第一张幻灯片时才有效?

为什么这个 Beamer 普通选项仅在它不是第一张幻灯片时才有效?

我正在尝试为我的大学改编一个非官方的 Beamer 模板(GitHub背页)。现在,当我尝试编译这个MWE时:

\documentclass{beamer}

\usetheme[bgphoto]{polimi}

\title[MS thesis]{Thesis title}
\subtitle{Master Thesis in Computer Science and Engineering}
\author[Alessandro Bertulli]{Alessandro Bertulli, matr. xxxxxx}
\date[05/10/2023]{5th October 2023}

\begin{document}
\begin{frame}
  \maketitle
\end{frame}

\section{Introduction}
\begin{frame}[plain]{}
    \sectionpage
\end{frame}

\end{document}

我得到这个为sectionpage

在此处输入图片描述

我想要删除标题,IIUC 应该使用 as 选项的效果plain。显然,这只有在它不是标题后的第一张幻灯片时才有效,如第二个 MWE 所示:

\documentclass{beamer}

\usetheme[bgphoto]{polimi}

\title[MS thesis]{Thesis title}
\subtitle{Master Thesis in Computer Science and Engineering}
\author[Alessandro Bertulli]{Alessandro Bertulli, matr. xxxxxx}
\date[05/10/2023]{5th October 2023}

\begin{document}
\begin{frame}
  \maketitle
\end{frame}

\begin{frame}

\end{frame}

\section{Introduction}
\begin{frame}[plain]{}
    \sectionpage
\end{frame}

\end{document}

这使 在此处输入图片描述

原因何在?谢谢!


为了完整性,我在这里发布样式文件:

beamerthemepolimi.sty

% Pasquale Africa <[email protected]>
% Beamer port of the official PoliMi presentation theme.

\mode<all>

\newif\if@bgphoto
\@bgphotofalse
\DeclareOption{bgphoto}{\@bgphototrue}

\newif\if@nologo
\@nologofalse
\DeclareOption{nologo}{\@nologotrue}
\ProcessOptions

\RequirePackage{tikz}
\usetikzlibrary{calc}
\graphicspath{{beamerthemepolimi_img/}}

\RequirePackage{etoolbox} % \patchcmd

\useinnertheme{polimi}
\useoutertheme{polimi}
\usecolortheme{polimi}

\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{itemize items}[square]
\setbeamertemplate{itemize subitem}[triangle]

% Set margins.
\setbeamersize{text margin left=\xshift, text margin right=\xshift}
\setlength{\leftmargini}{\xshift}

\let\oldtoc\tableofcontents
\renewcommand{\tableofcontents}[1][]{%
    \hspace*{0.5\xshift}
    \begin{minipage}{\textwidth}
        \oldtoc[#1]
    \end{minipage}
}

beamerouterthemepolimi.sty

\mode<presentation>

\newlength{\xshift}
\setlength{\xshift}{0.05\paperwidth}

% Header.
\defbeamertemplate*{frametitle}{polimi}
{
    \begin{tikzpicture}[overlay, remember picture]
    \node at ([shift={(\xshift, -0.6)}] current page.north west) [anchor=south west, inner sep=0pt]
    {
        {\small \insertsectionhead \ifx\insertsubsection\empty\else\ - \insertsubsectionhead\fi\leavevmode}
    };
    \node at ([shift={(\xshift, -1.25)}] current page.north west) [anchor=south west, inner sep=0pt]
    {
        \insertframetitle
    };
    \end{tikzpicture}
    \vspace{1.1cm}
}

% Header.
\defbeamertemplate*{frametitle}{plain}{}

% Use frametitle template even if \frametitle is empty.
\patchcmd{\endbeamer@frameslide}{\ifx\beamer@frametitle\@empty}{\iffalse}{}{\errmessage{Failed to patch frametitle.}}

% Footer.
\defbeamertemplate{footline}{polimi}{
    \begin{minipage}[b][1cm][c]{\paperwidth}
        \ifnum\c@framenumber>0
            \begin{tikzpicture}[overlay, remember picture]
            \node at ([shift={(\xshift, 0.5)}] current page.south west) [anchor=west, inner sep=0pt]
            {
                {\scriptsize\color{white} \insertauthor}
            };
            \node at ([shift={(-0.5\xshift, 0.5)}] current page.south east) [anchor=east, inner sep=0pt]
            {
                \includegraphics[height=\baselineskip]{logo_bandiera.png}
            };
            \end{tikzpicture}
        \fi
    \end{minipage}
}

\setbeamertemplate{footline}[polimi]

% Enable nonumber option.
\BeforeBeginEnvironment{frame}{
    \setbeamertemplate{background}[polimi]
    \setbeamertemplate{frametitle}[polimi]
    \setbeamertemplate{headline}[frame number]
}

\makeatletter
\define@key{beamerframe}{nonumber}[true]{
    \setbeamertemplate{headline}{}
    \addtocounter{framenumber}{-1}
}
\makeatother

% Enable plain option.
\makeatletter
\define@key{beamerframe}{plain}[true]{
    \ifnum\c@framenumber>0
        \setbeamertemplate{background}[footer]
        \setbeamertemplate{frametitle}[plain]
        \setbeamertemplate{headline}{}
        \addtocounter{framenumber}{-1}
    \fi
}
\makeatother

beamerinnerthemepolimi.sty

\mode<presentation>

% Background.
\defbeamertemplate*{background}{polimi}{
    % Titlepage.
    \ifnum\c@framenumber=0
        \begin{tikzpicture}[overlay, remember picture]
            \if@bgphoto
                \node at (current page.north) [anchor=north, inner sep=0pt] {\includegraphics[width=\paperwidth]{bgphoto_cut.jpg}};
            \fi
            \node (foot) at (current page.south) [anchor=south, minimum width=\paperwidth, minimum height=0.4415\paperheight, fill=bluePolimi] {};
            \if@nologo\else
                \node at (foot.north) [anchor=south, inner sep=0.5cm] {
                    \if@bgphoto
                        \includegraphics[width=0.3\paperwidth]{logo_centrato_COL_negativo.png}
                    \else
                        \includegraphics[width=0.3\paperwidth]{logo_centrato_COL_positivo.png}
                    \fi
                };
            \fi
            \node at ([shift={(0, -0.1)}] foot.north) {\includegraphics[width=\paperwidth]{decoration.pdf}};
        \end{tikzpicture}
    \else
        \begin{tikzpicture}[overlay, remember picture]
            \node (head) at (current page.north) [anchor=north, minimum width=\paperwidth, minimum height=0.1835\paperheight, fill=bluePolimi] {};
            \node at ([shift={(0, 0.1)}] head.south) {\includegraphics[width=\paperwidth]{decoration.pdf}};
            \node (foot) at (current page.south) [anchor=south, minimum width=\paperwidth, minimum height=0.105\paperheight, fill=bluePolimi] {};
        \end{tikzpicture}
    \fi
}

% Only footer background.
\defbeamertemplate*{background}{footer}{
    \begin{tikzpicture}[overlay, remember picture]
    \node (foot) at (current page.south) [anchor=south, minimum width=\paperwidth, minimum height=0.105\paperheight, fill=bluePolimi] {};
    \end{tikzpicture}
}

% Title page.
\defbeamertemplate*{title page}{polimi}[1][]
{
    \color{white}
    \vspace{4.25cm}
    
    \begin{minipage}[t][\baselineskip]{\paperwidth}
        {\Large\bf \inserttitle}
    \end{minipage}
    \\[\baselineskip]
    \begin{minipage}[t][2\baselineskip]{\paperwidth}
        {\large \insertsubtitle}
    \end{minipage}
    
    \vfill
    
    \begin{minipage}[t][\baselineskip]{\paperwidth}
        {\large\bf \insertauthor}
    \end{minipage}
    
    \begin{minipage}[t][\baselineskip]{\paperwidth}
        \insertdate
    \end{minipage}
    
    \vfill
    
    \addtocounter{framenumber}{-1}
}

% Table of Contents.
\setbeamertemplate{section in toc}[circle]
\setbeamertemplate{subsection in toc}{\leavevmode \leftskip=0.7em {\color{bluePolimi} $\bullet$} \hskip1pt \inserttocsubsection\par}  

% Section page.
\defbeamertemplate*{section page}{polimi}{
    \begin{tikzpicture}[overlay, remember picture]
        \node (foot) at (current page.south) [anchor=south, minimum width=\paperwidth, minimum height=0.4415\paperheight, fill=bluePolimi] {};
        \node at ([shift={(0, -0.1)}] foot.north) {\includegraphics[width=\paperwidth]{decoration.pdf}};
        % \path let \p1 = ([shift={(0, 0.105\paperheight+0.25)}] current page.south west), \p2 = (current page.east) in (\x1, \y1) edge [white, line width=0.5] (\x2, \y1);
        \node at ([shift={(\xshift, 3.5)}] current page.south west) [anchor=north west, inner sep=0pt, text width=\textwidth]
        {
            {\color{white}\Large\bf \insertsection}
        };
    \end{tikzpicture}
}
\setbeamertemplate{section page}[polimi]


% Subsection page.
\defbeamertemplate*{subsection page}{polimi}{
    \begin{tikzpicture}[overlay, remember picture]
    \node (foot) at (current page.south) [anchor=south, minimum width=\paperwidth, minimum height=0.4415\paperheight, fill=bluePolimi] {};
    \node at ([shift={(0, -0.1)}] foot.north) {\includegraphics[width=\paperwidth]{decoration.pdf}};
    % \path let \p1 = ([shift={(0, 0.105\paperheight+0.25)}] current page.south east), \p2 = (current page.west) in (\paperwidth,\y1) edge [white, line width=0.5] (\x2,\y1);
    \node at ([shift={(\xshift, 3.5)}] current page.south west) [anchor=north west, inner sep=0pt, text width=\textwidth]
    {
        {\color{white}\Large\bf \insertsubsection}
    };
    \end{tikzpicture}
}
\setbeamertemplate{subsection page}[polimi]

编辑: beamercolorthemepolimi.sty

\mode<presentation>

\definecolor{bluePolimi}{RGB}{114, 143, 165}
\definecolor{greenPolimi}{RGB}{0, 110, 0}
\definecolor{redPolimi}{RGB}{180, 0, 0}

\setbeamercolor{frametitle}{fg=white}

\setbeamercolor{normal text}{fg=black,bg=white}
\setbeamercolor{alerted text}{fg=redPolimi}
\setbeamercolor{example text}{fg=greenPolimi}

\setbeamercolor{block title}{bg=bluePolimi, fg=white}
\setbeamercolor{block body}{bg=bluePolimi!10!white, fg=black}

\setbeamercolor{block title alerted}{bg=redPolimi, fg=white}
\setbeamercolor{block body alerted}{bg=redPolimi!10!white, fg=black}

\setbeamercolor{block title example}{bg=greenPolimi, fg=white}
\setbeamercolor{block body example}{bg=greenPolimi!10!white, fg=black}

\setbeamercolor{itemize item}{fg=bluePolimi}
\setbeamercolor{itemize subitem}{fg=bluePolimi}

\setbeamercolor{section in toc}{fg=black}
\setbeamercolor{subsection in toc}{fg=black}
\setbeamercolor{section number projected}{bg=bluePolimi}

\setbeamercolor{page number in head/foot}{fg=white}

答案1

由于某种原因,您的主题重新定义了plain框架选项,使其仅适用于框架编号> 0。同时,它将普通框架的框架编号减少一,这意味着,如果普通框架之前没有正常框架,则其框架编号将是0,因此您的主题不会删除标题。

您可以重新定义重新定义的普通框架选项,使其适用于所有框架,如下所示:

\documentclass{beamer}

\usetheme[bgphoto]{polimi}

\title[MS thesis]{Thesis title}
\subtitle{Master Thesis in Computer Science and Engineering}
\author[Alessandro Bertulli]{Alessandro Bertulli, matr. xxxxxx}
\date[05/10/2023]{5th October 2023}

\makeatletter
\define@key{beamerframe}{plain}[true]{
%    \ifnum\c@framenumber>0
        \setbeamertemplate{background}[footer]
        \setbeamertemplate{frametitle}[plain]
        \setbeamertemplate{headline}{}
        \addtocounter{framenumber}{-1}
%    \fi
}
\makeatother

\begin{document}


\section{Introduction}
\begin{frame}[plain]
    \sectionpage
\end{frame}

\begin{frame}[plain]
    \sectionpage
\end{frame}

\end{document}

相关内容