自定义 beamer 主题上的条件导航栏

自定义 beamer 主题上的条件导航栏

我正在尝试创建自定义 beamer 模板。但是,我无法让导航栏在 中正确运行title page

如图所示,导航栏应该在的位置,但导航栏变成了白色。如何才能让它完全不可见,让背景填满整个框架?并同时保留其他幻灯片上的导航栏。

在此处输入图片描述

正如你所看到的,我尝试了几件事:

  • 重写\titlepage命令以自动重新定义该headline部分,但是没有作用。奖励:我真的很想要这些解决方案,因为它允许我删除footlines或其他需要从中删除的调整title page但是,我无法控制声明的宏的扩展。
  • headline在示例中调用之前手动重置。但是,我更喜欢自动解决方案。
  • \ifnum\thepage>1\relax在标题上添加条件 ( ) 以在第一页上表现不同,但它也会从第一张幻灯片中删除导航栏。这是我得到的最接近的解决方案。

代码如下:

\documentclass[compress]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}

\title{There Is No Largest Prime Number}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{[email protected]}}

%\usetheme{udp}

%% Color theme
\definecolor{frontColor}{RGB}{119,95,85}%MedianBrown
\definecolor{firstColor}{RGB}{148,182,210}%MedianLightBlue
\definecolor{secondColor}{RGB}{221,128,71}%MedianOrange

% Settings
\setbeamercolor*{title page header}{fg=white}
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{item}{fg=secondColor}
%color for the navigation bar
\setbeamercolor*{section in head/foot}{fg=white,bg=black}

%% beameroutertheme
%headline with navigation bar
% I need to change this to behave differently on the title page    
\setbeamertemplate{headline}
{%
%\ifnum\thepage>1\relax%
\begin{beamercolorbox}[wd=\the\paperwidth,ht=0.6cm]{section in head/foot}
  \begin{tikzpicture}
    \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,0.6);
    \fill[secondColor] (0,0) rectangle(0.3,0.6);
    \fill[firstColor] (0.35,0) rectangle(\the\paperwidth,0.6);
    \node[anchor= west, white] at (0.3,0.3){\insertnavigation{0.85\paperwidth}};%
  \end{tikzpicture}
\end{beamercolorbox}
%\fi
}

% Frame title
\defbeamertemplate*{frametitle}{udp}[1][]
{%
\vskip-1pt%skip after the begginning of the slide
  \begin{beamercolorbox}[wd=\paperwidth,ht=0.6cm]{frametitle} 
  \begin{tikzpicture}
    \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,0.6);
    \fill[secondColor] (0,0) rectangle(0.3,1);
    \fill[firstColor] (0.35,0) rectangle(\the\paperwidth,0.6);
    {\node[anchor=west, white,font=\large] at (0.4,0.3){\insertframetitle};}
  \end{tikzpicture}
  \end{beamercolorbox}
}


%% beamerinnertheme
\setbeamertemplate{background}{
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
    \fill[color=frontColor] (0,2) rectangle (\the\paperwidth,\the\paperheight);
    \fill[color=secondColor] (0,0) rectangle(2.95,1.9);
    \fill[color=firstColor] (3.05,0) rectangle(\the\paperwidth,1.9);
    \ifnum\thepage>1\relax%
      \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
    \fi
  \end{tikzpicture}
}

% Title page
\defbeamertemplate*{title page}{udp}[1][]
{%
  %do the title page
  \vskip0.5cm%
  \begin{minipage}[r]{\linewidth}
    \begin{flushright}
      % logo goes here
    \end{flushright}
  \end{minipage}
  \vskip0.5cm%
  \begin{minipage}[t][5cm][b]{\textwidth}
    \begin{beamercolorbox}[wd=\the\paperwidth,leftskip=3cm,sep=8pt,#1]{title page header}
      \usebeamerfont{title}\inserttitle\par%
    \end{beamercolorbox}%
  \end{minipage}
  \vskip0.5cm%
  \begin{minipage}[c][1.6cm][c]{\textwidth}
    \begin{beamercolorbox}[wd=\the\paperwidth,leftskip=3.5cm,#1]{author}
      \usebeamerfont{author}\insertauthor%
    \end{beamercolorbox}
     \vskip0.2cm%
    \begin{beamercolorbox}[wd=\the\paperwidth,leftskip=3.5cm,#1]{date}
      \usebeamerfont{author}\insertdate%
  \end{beamercolorbox}
  \end{minipage}
  \vfill
}

% I also tried to fix the title page navigation bar by redefining the title command
%\def\oldtitlepage\titlepage
%\def\titlepage{\setbeamertemplate{headline}{test}\oldtitlepage}

% Items
\setbeamertemplate{items}[square]
\setbeamertemplate{sections/subsections in toc}[square]    

\begin{document}
{% I tried to remove the headline here
\setbeamertemplate{headline}{}
\begin{frame}
\titlepage
\end{frame}
}
\section{First section}
\subsection{1}

\begin{frame} 
\frametitle{There Is No Largest Prime Number} 
\framesubtitle{The proof uses \textit{reductio ad absurdum}.} 
\begin{theorem}
There is no largest prime number. \end{theorem} 
\end{frame}

\begin{frame} 
\frametitle{There Is No Largest Prime Number} 
\framesubtitle{The proof uses \textit{reductio ad absurdum}.} 
\begin{theorem}
There is no largest prime number. \end{theorem} 
\end{frame}

\end{document}

答案1

您尝试设置的条件可以通过以下方式实现\insertframenumber

\ifnum\insertframenumber>1\relax%
<code for the naviagtion bar>
\fi

完整示例:

\documentclass[compress]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}

\title{There Is No Largest Prime Number}
\date[ISPN ’80]{27th International Symposium of Prime Numbers}
\author[Euclid]{Euclid of Alexandria \texttt{[email protected]}}

%\usetheme{udp}

%% Color theme
\definecolor{frontColor}{RGB}{119,95,85}%MedianBrown
\definecolor{firstColor}{RGB}{148,182,210}%MedianLightBlue
\definecolor{secondColor}{RGB}{221,128,71}%MedianOrange

% Settings
\setbeamercolor*{title page header}{fg=white}
\setbeamercolor*{author}{fg=white}
\setbeamercolor*{date}{fg=white}
\setbeamercolor*{item}{fg=secondColor}
%color for the navigation bar
\setbeamercolor*{section in head/foot}{fg=white,bg=black}

%% beameroutertheme
%headline with navigation bar
% I need to change this to behave differently on the title page    
\setbeamertemplate{headline}
{%
\leavevmode
\ifnum\insertframenumber>1\relax%
\begin{beamercolorbox}[wd=\the\paperwidth,ht=0.6cm]{section in head/foot}
  \begin{tikzpicture}
    \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,0.6);
    \fill[secondColor] (0,0) rectangle(0.3,0.6);
    \fill[firstColor] (0.35,0) rectangle(\the\paperwidth,0.6);
    \node[anchor= west, white] at (0.3,0.3){\insertnavigation{0.85\paperwidth}};%
  \end{tikzpicture}
\end{beamercolorbox}
\fi
\vskip-17pt% Hack: just to prevent overfull \vboxes
}

% Frame title
\defbeamertemplate*{frametitle}{udp}[1][]
{%
\vskip-1pt%skip after the begginning of the slide
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle} 
  \begin{tikzpicture}
    \useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,0.6);
    \fill[secondColor] (0,0) rectangle(0.3,1);
    \fill[firstColor] (0.35,0) rectangle(\the\paperwidth,0.6);
    {\node[anchor=west, white,font=\large] at (0.4,0.3){\insertframetitle};}
  \end{tikzpicture}
  \end{beamercolorbox}
}


%% beamerinnertheme
\setbeamertemplate{background}{
  \begin{tikzpicture}
    \useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
    \fill[color=frontColor] (0,2) rectangle (\the\paperwidth,\the\paperheight);
    \fill[color=secondColor] (0,0) rectangle(2.95,1.9);
    \fill[color=firstColor] (3.05,0) rectangle(\the\paperwidth,1.9);
    \ifnum\thepage>1\relax%
      \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
    \fi
  \end{tikzpicture}
}

% Title page
\defbeamertemplate*{title page}{udp}[1][]
{%
  %do the title page
  \vskip0.5cm%
  \begin{minipage}[r]{\linewidth}
    \begin{flushright}
      % logo goes here
    \end{flushright}
  \end{minipage}
  \vskip0.5cm%
  \begin{minipage}[t][5cm][b]{\textwidth}
    \begin{beamercolorbox}[wd=\the\paperwidth,leftskip=3cm,sep=8pt,#1]{title page header}
      \usebeamerfont{title}\inserttitle\par%
    \end{beamercolorbox}%
  \end{minipage}
  \vskip0.5cm%
  \begin{minipage}[c][1.6cm][c]{\textwidth}
    \begin{beamercolorbox}[wd=\the\paperwidth,leftskip=3.5cm,#1]{author}
      \usebeamerfont{author}\insertauthor%
    \end{beamercolorbox}
     \vskip0.2cm%
    \begin{beamercolorbox}[wd=\the\paperwidth,leftskip=3.5cm,#1]{date}
      \usebeamerfont{author}\insertdate%
  \end{beamercolorbox}
  \end{minipage}
  \vfill
}

% I also tried to fix the title page navigation bar by redefining the title command
%\def\oldtitlepage\titlepage
%\def\titlepage{\setbeamertemplate{headline}{test}\oldtitlepage}

% Items
\setbeamertemplate{items}[square]
\setbeamertemplate{sections/subsections in toc}[square]    

\begin{document}
{% I tried to remove the headline here
\setbeamertemplate{headline}{}
\begin{frame}
\titlepage
\end{frame}
}
\section{First section}
\subsection{1}

\begin{frame} 
\frametitle{There Is No Largest Prime Number} 
\framesubtitle{The proof uses \textit{reductio ad absurdum}.} 
\begin{theorem}
There is no largest prime number. \end{theorem} 
\end{frame}

\begin{frame} 
\frametitle{There Is No Largest Prime Number} 
\framesubtitle{The proof uses \textit{reductio ad absurdum}.} 
\begin{theorem}
There is no largest prime number. \end{theorem} 
\end{frame}

\end{document}

在此处输入图片描述

相关内容