文档.tex

文档.tex

我正在开发自己的 Beamer 主题。作为主题的一部分,我希望部分幻灯片的标题与其他幻灯片位于相同的位置。

此时位置有点偏离。正常的幻灯片是这样的,

正常帧头

该部分幻灯片如下,

在此处输入图片描述

我开发的代码如下所示。

文档.tex

 \documentclass[t,10pt]{beamer}
 \usepackage{bookmark}
 \usepackage{amssymb,amsmath}
 \usepackage{ifxetex,ifluatex}
 \usepackage[english]{babel}
 \usepackage{longtable,booktabs}
 \usepackage{graphicx}
 \usepackage{beamerthemeBeamerSOME}

 \begin{document}

 \begin{frame}{Welcome}
 \end{frame}

 \section*{Introduction to R syntax}
 \frame{\sectionpage[yellow]}

 \end{document}

beamerthemeBeamerSOME.sty

 \ProvidesPackage{beamerthemeBeamerSOME}[2007/05/05 v1.3 for beamer 3.01]

 \mode<presentation>

 % Import of standard packages
 \usepackage[english]{babel}
 \usepackage{xcolor}
 \usepackage{tikz}
 \usepackage{graphicx}
 \usepackage{bookmark}
 \usepackage{etoolbox}

 % Set fonts to Arial
 \usepackage[no-math]{fontspec}
 \setmainfont{Arial}
 \setsansfont{Arial}

 % Color Definitions
 \definecolor{darkgray}{RGB}{64,64,64}
 \definecolor{yellow}{RGB}{255,210,0}
 \usecolortheme[RGB={255,210,0}]{structure}

 \providebool{SHOW_LINE_IN_FOOTER}
 \providebool{DIVIDER_IS_YELLOW}
 \boolfalse{SHOW_LINE_IN_FOOTER}
 \booltrue{DIVIDER_IS_YELLOW}

 \newif\ifbeamer@secheader
 \beamer@secheaderfalse

 \DeclareOptionBeamer{secheader}{\beamer@secheadertrue}
 \ProcessOptionsBeamer

 \useinnertheme{SOME}
 \useoutertheme{infolinesSOME}

 \setbeamerfont{title}{size=\fontsize{15}{17},series=\bfseries}
 \setbeamerfont{subtitle}{size=\fontsize{15}{17},series=\bfseries}
 \setbeamerfont{date}{size =\fontsize{10.5}{11}}
 \setbeamerfont{frametitle}{series=\bfseries}
 \setbeamercolor{frametitle}{fg=darkgray,bg=white}

 \setbeamersize{text margin left=1em,text margin right=1em}

 \mode<all>

beamerinnerthemeSOME

 \ProvidesPackage{beamerinnerthemeSOME}[2004/12/20 v1.0 for beamer 3.01]
 \usepackage{xcolor}
 \usepackage{tikz}
 \usepackage{graphicx}
 \usepackage{etoolbox}
 \usepackage{xparse}

 \ProcessOptionsBeamer

 \mode<presentation>

 \setbeamertemplate{section page}{
   \global\boolfalse{SHOW_LINE_IN_FOOTER}
   \ifbool{DIVIDER_IS_YELLOW}{%
     \begin{tikzpicture}[remember picture, overlay]
       \node at (current page.center) {
         \includegraphics[width=\paperwidth]{yellow_divider.pdf}
       };
     \end{tikzpicture}}{%
     \begin{tikzpicture}[remember picture, overlay]
       \node at (current page.center) {
         \includegraphics[width=\paperwidth]{gray_divider.pdf}
       };
     \end{tikzpicture}}

   \global\booltrue{DIVIDER_IS_YELLOW}%
   % Code from beamerouterthemedefault.sty

   \strut\usebeamerfont{frametitle}\insertsectionhead\strut
 }

 \let\oldsectionpage\sectionpage
 \renewcommand{\sectionpage}[1][\@nil]{%
   \def\tmp{#1}%
   \ifx\tmp\@nnil%
     \global\booltrue{DIVIDER_IS_YELLOW}%
   \else%
     \edef\mytemp{{#1}}%
     \expandafter\ifstrequal\mytemp{gray}{\global\boolfalse{DIVIDER_IS_YELLOW}}{%
       \global\booltrue{DIVIDER_IS_YELLOW}}%
     \fi%
   \oldsectionpage%
 }

 \makeatother

 \mode<all>

beamerouterthemeinfolinesSOME.sty

 \ProvidesPackage{beamerouterthemeinfolinesSOME}[2004/11/27 v1.0 for beamer 3.01]
 \usepackage{etoolbox}


 \mode<presentation>

 \setbeamercolor*{author in head/foot}{parent=palette tertiary}
 \setbeamercolor*{title in head/foot}{parent=palette secondary}
 \setbeamercolor*{footer info}{parent=palette primary}

 \setbeamercolor*{section in head/foot}{parent=palette tertiary}
 \setbeamercolor*{subsection in head/foot}{parent=palette primary}

 \setbeamercolor{normal text}{fg=darkgray}
 \setbeamercolor{palette primary}{fg=darkgray,bg=white}
 \setbeamercolor{palette secondary}{fg=white,bg=darkgray}
 \setbeamercolor*{palette tertiary}{fg=darkgray, bg=white}
 \setbeamercolor{normal text}{fg=darkgray}
 \setbeamercolor{section number projected}{fg=white,bg=darkgray}

 \setbeamertemplate{frametitle}
 {
    \vskip4pt
    \insertframetitle
    \par
    \vskip5pt

   \color{yellow}
   \centering
   \rule{0.94\paperwidth}{0.9pt}
 }

 \setbeamertemplate{footline}
 {
   \leavevmode
   \centering

   \ifbool{SHOW_LINE_IN_FOOTER}{%
     \rule{0.94\paperwidth}{0.2pt}}{\global\booltrue{SHOW_LINE_IN_FOOTER}}
   \vskip5pt
   \hbox{
      \begin{beamercolorbox}[wd=.02\paperwidth,ht=0.0ex,dp=3ex,left]{footer info}%
       % dummy box
      \end{beamercolorbox}%

      \begin{beamercolorbox}[wd=.1\paperwidth,ht=4ex,dp=1ex,left]{footer info}%
        \usebeamerfont{author in head/foot}
         Page \insertframenumber{}
      \end{beamercolorbox}%

      \begin{beamercolorbox}[wd=.2\paperwidth,ht=4ex,dp=1ex,center]{footer info}%
        \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
      \end{beamercolorbox}%

      \begin{beamercolorbox}[wd=.5\paperwidth,ht=4ex,dp=1ex,left]{footer info}%
        \usebeamerfont{date in head/foot}\insertshorttitle
      \end{beamercolorbox}

      \begin{beamercolorbox}[wd=.03\paperwidth,ht=0.0ex,dp=3ex,left]{footer info}%
       % dummy box
      \end{beamercolorbox}%
   }
   \vskip2pt
 }

 \makeatletter
 \defbeamertemplate{note page}{plain2}
 {
   \vskip2.25em
   \nointerlineskip
   \begin{minipage}{0.95\textwidth} % this is an addition
   \insertnote
   \end{minipage}               % this is an addition
 }
 \makeatother
 \setbeamertemplate{note page}[plain2]

 \mode
 <all>

答案1

所以我最终手动破解了垂直间距。

beamerInnerThemeSOME.sty

 \ProvidesPackage{beamerinnerthemeSOME}[2004/12/20 v1.0 for beamer 3.01]
 \usepackage{xcolor}
 \usepackage{tikz}
 \usepackage{graphicx}
 \usepackage{etoolbox}
 \usepackage{xparse}

 \ProcessOptionsBeamer

 \mode<presentation>

 \setbeamertemplate{section page}{
   \global\boolfalse{SHOW_LINE_IN_FOOTER}
   \ifbool{DIVIDER_IS_YELLOW}{%
     \begin{tikzpicture}[remember picture, overlay]
       \node at (current page.center) {
         \includegraphics[width=\paperwidth]{yellow_divider.pdf}
       };
     \end{tikzpicture}}{%
     \begin{tikzpicture}[remember picture, overlay]
       \node at (current page.center) {
         \includegraphics[width=\paperwidth]{gray_divider.pdf}
       };
     \end{tikzpicture}}

   \global\booltrue{DIVIDER_IS_YELLOW}%
   % Code from beamerouterthemedefault.sty

   % Adjust spacing which solves the vertical alginment problem.
   \vskip-0.95em

   \strut\usebeamerfont{frametitle}\insertsectionhead\strut
 }

 \let\oldsectionpage\sectionpage
 \renewcommand{\sectionpage}[1][\@nil]{%
   \def\tmp{#1}%
   \ifx\tmp\@nnil%
     \global\booltrue{DIVIDER_IS_YELLOW}%
   \else%
     \edef\mytemp{{#1}}%
     \expandafter\ifstrequal\mytemp{gray}{\global\boolfalse{DIVIDER_IS_YELLOW}}{%
       \global\booltrue{DIVIDER_IS_YELLOW}}%
     \fi%
   \oldsectionpage%
 }

 \makeatother

 \mode<all>

相关内容