\beamercolorbox 在样式文件中的位置

\beamercolorbox 在样式文件中的位置

我正在设计(实际上是修改现有的)样式文件。我想要顶部和底部的水平条。我可以在所有的页面上得到这些,但我无法得到位于标题页最顶部的水平条。这是我调用的样式文件中的内容beamerthememystyle(我删除了顶部的 acks 以简化):

\mode<presentation>

\RequirePackage{tgpagella}
\RequirePackage{tikz}

\useoutertheme{default}
\useinnertheme{default}
\usefonttheme{serif}

% Puts a line at the foot and also adds slide number
\setbeamertemplate{footline} % show slide number on all slides but the first
{%
  \ifnum\c@framenumber=1
  \else
    \begin{beamercolorbox}[wd=0.98\paperwidth,right,dp=1ex]{page number}
        \tiny\insertframenumber
     \end{beamercolorbox}
  \fi%
  \begin{beamercolorbox}[ht=4pt]{lower separation line foot}
  \end{beamercolorbox}
}

% Puts a line at the top
\setbeamertemplate{headline} 
{%
  \begin{beamercolorbox}[ht=4pt]{upper separation line head}
  \end{beamercolorbox}
}

% 2. plain title page
\titlegraphic{\includegraphics[width=0.8\textwidth]{DSG-Logo_horiz}}
\usetitlepagetemplate{%
  \leavevmode 
  \hbox{\begin{beamercolorbox}[ht=4pt,wd=\paperwidth]{upper separation line head}
  \end{beamercolorbox}}
  \vfill
  \begin{center}
    \LARGE\structure{\inserttitle}
    \vskip1em\par
    \normalsize\insertauthor\par
    {\small\insertinstitute\par}\par\vskip1em
    \par\vskip2em
    {\scriptsize\insertdate}\par\vskip2em
    \inserttitlegraphic
  \end{center}
  \vfill
}


% Display a slide before the current section with overview inf
\AtBeginSection[]
{%
   \begin{frame}
       \frametitle{Overview}
       \tableofcontents[currentsection,hideothersubsections]
   \end{frame}
}

\definecolor{mycolour}{HTML}{A52A2A}

\setbeamercolor*{item}{fg=mycolour}
\setbeamercolor{itemize subitem}{fg=mycolour}

\setbeamerfont{title like}{shape=\scshape}
\setbeamerfont{frametitle}{shape=\scshape}
\setbeamerfont{section in head/foot}{shape=\scshape,size=\tiny}

\setbeamertemplate{navigation symbols}{} % hide bottom nav buttons
\setbeamercovered{transparent} % don't hide strip-teased bullet points

\setbeamercolor{upper separation line head}{bg=mycolour} 
\setbeamercolor{upper separation line foot}{bg=mycolour} 

\setbeamercolor{lower separation line head}{bg=mycolour} 
\setbeamercolor{lower separation line foot}{bg=mycolour} 
\setbeamercolor{normal text}{fg=black,bg=white} 
\setbeamercolor{alerted text}{fg=red} 
\setbeamercolor{example text}{fg=black} 
\setbeamercolor{structure}{fg=black} 
 
\setbeamercolor{palette tertiary}{fg=black,bg=black!10} 
\setbeamercolor{palette quaternary}{fg=black,bg=black!10} 

\mode<all>

最初,我没有台词

  \leavevmode 
  \hbox{\begin{beamercolorbox}[ht=4pt,wd=\paperwidth]{upper separation line head}
  \end{beamercolorbox}}

期望\usetitlepagetemplate{}这样\setbeamertemplate{headline}做可以实现这一点——但确实如此,但不是在标题页上。然后我添加了这些行,但它放置的水平条不在顶部,而是向下推(我认为是在顶部边距)。我怎样才能在标题页上获得与其他页面相同的条?

这是我使用的测试文件的 MWE:

\documentclass{beamer}

\usetheme{mystyle}

\title[Testing-short]{Testing}
\author{M. Tamer \"Ozsu}
\institute{University of Waterloo}

\begin{document}
  {%
    \setbeamertemplate{headline}{}
    \frame{\titlepage}
  }

  \begin{frame}
   \frametitle{We are testing...}
    It's working!
  \end{frame}
\end{document}

在此处输入图片描述

在此处输入图片描述

答案1

问题是,如果您使用\setbeamertemplate{headline}{}清除标题的内容,标题仍然会有其高度。

两种可能的解决方案:

  1. 使用plain框架来显示标题,但你还必须在标题页上添加下一行

  2. 不要删除标题。将此行用作标题页,不要在标题页模板中添加第二行


\mode<presentation>

\RequirePackage{tgpagella}
\RequirePackage{tikz}

\useoutertheme{default}
\useinnertheme{default}
\usefonttheme{serif}

% Puts a line at the foot and also adds slide number
\setbeamertemplate{footline} % show slide number on all slides but the first
{%
  \ifnum\c@framenumber=1
  \else
    \begin{beamercolorbox}[wd=0.98\paperwidth,right,dp=1ex]{page number}
        \tiny\insertframenumber
     \end{beamercolorbox}
  \fi%
  \begin{beamercolorbox}[ht=4pt]{lower separation line foot}
  \end{beamercolorbox}
}

% Puts a line at the top
\setbeamertemplate{headline} 
{%
  \begin{beamercolorbox}[ht=4pt]{upper separation line head}
  \end{beamercolorbox}
}

% 2. plain title page
\titlegraphic{\includegraphics[width=0.8\textwidth]{example-image-duck}}
\usetitlepagetemplate{%
  \leavevmode 
%  \hbox{\begin{beamercolorbox}[ht=4pt,wd=\paperwidth]{upper separation line head}
%  \end{beamercolorbox}}
  \vfill
  \begin{center}
    \LARGE\structure{\inserttitle}
    \vskip1em\par
    \normalsize\insertauthor\par
    {\small\insertinstitute\par}\par\vskip1em
    \par\vskip2em
    {\scriptsize\insertdate}\par\vskip2em
    \inserttitlegraphic
  \end{center}
  \vfill
}


% Display a slide before the current section with overview inf
\AtBeginSection[]
{%
   \begin{frame}
       \frametitle{Overview}
       \tableofcontents[currentsection,hideothersubsections]
   \end{frame}
}

\definecolor{mycolour}{HTML}{A52A2A}

\setbeamercolor*{item}{fg=mycolour}
\setbeamercolor{itemize subitem}{fg=mycolour}

\setbeamerfont{title like}{shape=\scshape}
\setbeamerfont{frametitle}{shape=\scshape}
\setbeamerfont{section in head/foot}{shape=\scshape,size=\tiny}

\setbeamertemplate{navigation symbols}{} % hide bottom nav buttons
\setbeamercovered{transparent} % don't hide strip-teased bullet points

\setbeamercolor{upper separation line head}{bg=mycolour} 
\setbeamercolor{upper separation line foot}{bg=mycolour} 

\setbeamercolor{lower separation line head}{bg=mycolour} 
\setbeamercolor{lower separation line foot}{bg=mycolour} 
\setbeamercolor{normal text}{fg=black,bg=white} 
\setbeamercolor{alerted text}{fg=red} 
\setbeamercolor{example text}{fg=black} 
\setbeamercolor{structure}{fg=black} 
 
\setbeamercolor{palette tertiary}{fg=black,bg=black!10} 
\setbeamercolor{palette quaternary}{fg=black,bg=black!10} 

\mode<all>

\documentclass{beamer}

\usetheme{mystyle}

\title[Testing-short]{Testing}
\author{M. Tamer \"Ozsu}
\institute{University of Waterloo}

\begin{document}
{
    \frame{\titlepage}
}
  \begin{frame}
   \frametitle{We are testing...}
    It's working!
  \end{frame}
\end{document}

在此处输入图片描述

相关内容