Latex beamer。只有前两张幻灯片有带有此特定主题的幻灯片编号:如何更改?

Latex beamer。只有前两张幻灯片有带有此特定主题的幻灯片编号:如何更改?

您可以在下面看到我的 .tex 脚本和 .sty 主题。使用此主题时,只有前两张幻灯片有幻灯片编号,而删除此主题时所有幻灯片都有编号。我知道我必须在 .sty 主题中更改一些内容,但经过几次尝试,我还没有找到解决方案。

\documentclass{beamer}


\usetheme{theme1}


\usepackage{graphicx}
\usepackage{hyperref} % allows clickable urls
\usepackage{tikz}
\usepackage{listings} % show code

\usepackage{tikz}
\usetikzlibrary{snakes}
\usetikzlibrary{positioning}
\newlength\yearposx
\makeatletter
\def\blfootnote{\gdef\@thefnmark{}\@footnotetext}
\makeatother

\definecolor{lightgrey}{RGB}{245,245,245}

% slide numbering
\setbeamertemplate{footline}{}

\addtobeamertemplate{navigation symbols}{}{%
    \usebeamerfont{footline}%
    \usebeamercolor[fg]{footline}%
    \hspace{1em}%
    \insertframenumber/\inserttotalframenumber
}

% define title page

% begin document
\begin{document}


    

\frame{
    \frametitle{a}
}

\frame{
    \frametitle{a}
}

\frame{
    \frametitle{a}
}

\frame{
    \frametitle{a}
}
\end{document}

主题主题1:

\RequirePackage{calc}
\RequirePackage{etoolbox}

\mode<presentation>

\newdimen\beamer@ubBorderHeight
\newdimen\beamer@ubTitleHeight
\newdimen\beamer@ubFooterHeight
\newdimen\beamer@ubOverlap

\beamer@ubOverlap=0.2pt
\beamer@ubBorderHeight=0.015\paperheight
\beamer@ubTitleHeight=0.125\paperheight
\beamer@ubFooterHeight=0.032\paperheight

\definecolor{ubRed}{HTML}{E6002E}
\definecolor{ubGrey}{RGB}{255,255,255}

\ProcessOptionsBeamer

\setbeamercolor{normal text}{fg=black}
\setbeamercolor{alerted text}{fg=ubRed}
\setbeamercolor{itemize item}{fg=ubRed}
\setbeamercolor{itemize subitem}{fg=ubRed}
\setbeamercolor{example text}{fg=black}
\setbeamercolor{structure}{fg=black}
\setbeamercolor{date in title page}{fg=black}

% set fonts
\RequirePackage[scaled]{helvet}
\renewcommand*\familydefault{\sfdefault}

\usefonttheme[onlymath]{serif}
\RequirePackage{iftex}
\ifPDFTeX
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\fi



\setbeamerfont*{structure}{series=\bfseries}
\setbeamerfont*{title}{size*={18}{22}}
\setbeamercolor*{title}{bg=ubRed}
\setbeamerfont*{subtitle}{size*={18}{22}}
\setbeamerfont*{author}{size*={10}{12},series=\bfseries}
\setbeamerfont*{institute}{size*={10}{12}}
\setbeamerfont*{frametitle}{size*={18}{22}}
\setbeamercolor*{frametitle}{fg=ubRed}
\setbeamerfont*{framesubtitle}{size*={18}{22}}
\setbeamercolor*{framesubtitle}{fg=black}
\setbeamerfont*{date}{size*={8}{10}}
\setbeamerfont*{headline}{size*={8}{10}}
\beamertemplatenavigationsymbolsempty

\defbeamertemplate*{title page}{uni bern}{%
  % list trick from https://texfaq.org/FAQ-chngmargonfly
  \begin{list}{}{
  \setlength{\listparindent}{\parindent}%
  \setlength{\itemindent}{\parindent}%
  \setlength{\parsep}{\parskip}%
  \setlength{\leftmargin}{0pt}%
  \setlength{\rightmargin}{0pt}}
  \item[]
  \vspace*{\stretch{2}}
  {\usebeamerfont*{title}\color{ubRed}\inserttitle\par} % no idea why usebeamercolor{title} does not work here
  {\usebeamerfont*{subtitle}\insertsubtitle\par}
  \vspace{\stretch{1}}
  {\usebeamerfont{author}\insertauthor\par}
  {\usebeamerfont{date}\insertdate\par}
  \vspace*{\stretch{2}}
  \end{list}
%  \end{minipage}
}

\defbeamertemplate*{background canvas}{uni bern}{%
\begin{minipage}[t]{\paperwidth+10pt}
   \setlength{\baselineskip}{0pt}
   \setlength{\lineskip}{-\beamer@ubOverlap}
   \setlength{\parskip}{0pt}
   \ifnumgreater{\c@framenumber}{1}{}{}

   \ifnumgreater{\c@framenumber}{2}{
        \ifdefempty{\insertframesubtitle}{
          \rule{0pt}{6ex+\beamer@ubTitleHeight}\\
          \color{ubGrey}\rule{\paperwidth}{\paperheight-\beamer@ubTitleHeight-\beamer@ubFooterHeight-6ex}
        }{
          \rule{0pt}{6ex+2\beamer@ubTitleHeight}\\          
          \color{ubGrey}\rule{\paperwidth}{\paperheight-2\beamer@ubTitleHeight-\beamer@ubFooterHeight-6ex}   
        }
   }{}
  \end{minipage}
}

\defbeamertemplate*{headline}{uni bern}{% 
    \ifnumgreater{\c@framenumber}{2}{
      \vspace{3.5ex}
      \hspace{4.5ex}\inserttitle
    }{}
}

\defbeamertemplate*{frametitle}{uni bern}{
\begin{minipage}[b]{\textwidth}
\vspace{0.5ex}
\raggedright
\vspace{3.5ex}
{\insertframetitle\par}
{\usebeamerfont{framesubtitle}\usebeamercolor*{framesubtitle}\insertframesubtitle}
\end{minipage}
}


% set bullets

\defbeamertemplate*{itemize item}{uni bern}{$\bullet$}
\defbeamertemplate*{itemize subitem}{uni bern}{$\bullet$}
\setbeamersize{text margin left=4ex}
\setbeamersize{text margin right=4ex}



\mode<all>

答案1

呃,这个主题做了很多非常糟糕的事情。

最糟糕的是标题。它的高度不仅在整个演示过程中发生变化,而无需重新计算框架几何形状,而且还使用\inserttitle高度可能变化的内容,例如,取决于标题是否像字母一样有下降部分g,或者甚至可能像您的示例中那样为空。

Beamer 无法让框架的其余部分适应这些变化,因为框架几何形状从未重新计算过。因此,导航符号有时会超出页面的可见区域。

可以通过在为此目的而制作的模板中放置页码来避免这个特定问题:footline,然而在使用此模板之前还应该修复所有其他问题。

\documentclass{beamer}

\makeatletter
\RequirePackage{calc}
\RequirePackage{etoolbox}

\mode<presentation>

\newdimen\beamer@ubBorderHeight
\newdimen\beamer@ubTitleHeight
\newdimen\beamer@ubFooterHeight
\newdimen\beamer@ubOverlap

\beamer@ubOverlap=0.2pt
\beamer@ubBorderHeight=0.015\paperheight
\beamer@ubTitleHeight=0.125\paperheight
\beamer@ubFooterHeight=0.032\paperheight

\definecolor{ubRed}{HTML}{E6002E}
\definecolor{ubGrey}{RGB}{255,255,255}

\ProcessOptionsBeamer

\setbeamercolor{normal text}{fg=black}
\setbeamercolor{alerted text}{fg=ubRed}
\setbeamercolor{itemize item}{fg=ubRed}
\setbeamercolor{itemize subitem}{fg=ubRed}
\setbeamercolor{example text}{fg=black}
\setbeamercolor{structure}{fg=black}
\setbeamercolor{date in title page}{fg=black}

% set fonts
\RequirePackage[scaled]{helvet}
\renewcommand*\familydefault{\sfdefault}

\usefonttheme[onlymath]{serif}
\RequirePackage{iftex}
\ifPDFTeX
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\fi



\setbeamerfont*{structure}{series=\bfseries}
\setbeamerfont*{title}{size*={18}{22}}
\setbeamercolor*{title}{bg=ubRed}
\setbeamerfont*{subtitle}{size*={18}{22}}
\setbeamerfont*{author}{size*={10}{12},series=\bfseries}
\setbeamerfont*{institute}{size*={10}{12}}
\setbeamerfont*{frametitle}{size*={18}{22}}
\setbeamercolor*{frametitle}{fg=ubRed}
\setbeamerfont*{framesubtitle}{size*={18}{22}}
\setbeamercolor*{framesubtitle}{fg=black}
\setbeamerfont*{date}{size*={8}{10}}
\setbeamerfont*{headline}{size*={8}{10}}
\beamertemplatenavigationsymbolsempty

\defbeamertemplate*{title page}{uni bern}{%
  % list trick from https://texfaq.org/FAQ-chngmargonfly
  \begin{list}{}{
  \setlength{\listparindent}{\parindent}%
  \setlength{\itemindent}{\parindent}%
  \setlength{\parsep}{\parskip}%
  \setlength{\leftmargin}{0pt}%
  \setlength{\rightmargin}{0pt}}
  \item[]
  \vspace*{\stretch{2}}
  {\usebeamerfont*{title}\color{ubRed}\inserttitle\par} % no idea why usebeamercolor{title} does not work here
  {\usebeamerfont*{subtitle}\insertsubtitle\par}
  \vspace{\stretch{1}}
  {\usebeamerfont{author}\insertauthor\par}
  {\usebeamerfont{date}\insertdate\par}
  \vspace*{\stretch{2}}
  \end{list}
%  \end{minipage}
}

\defbeamertemplate*{background canvas}{uni bern}{%
\begin{minipage}[t]{\paperwidth+10pt}
   \setlength{\baselineskip}{0pt}
   \setlength{\lineskip}{-\beamer@ubOverlap}
   \setlength{\parskip}{0pt}
   \ifnumgreater{\c@framenumber}{1}{}{}

   \ifnumgreater{\c@framenumber}{2}{
        \ifdefempty{\insertframesubtitle}{
          \rule{0pt}{6ex+\beamer@ubTitleHeight}\\
          \color{ubGrey}\rule{\paperwidth}{\paperheight-\beamer@ubTitleHeight-\beamer@ubFooterHeight-6ex}
        }{
          \rule{0pt}{6ex+2\beamer@ubTitleHeight}\\          
          \color{ubGrey}\rule{\paperwidth}{\paperheight-2\beamer@ubTitleHeight-\beamer@ubFooterHeight-6ex}   
        }
   }{}
  \end{minipage}
}

\defbeamertemplate*{headline}{uni bern}{% 
    \ifnumgreater{\c@framenumber}{2}{
      \vspace{3.5ex}
      \hspace{4.5ex}\inserttitle
      \vspace{-4.5ex}
    }{}
}

\defbeamertemplate*{frametitle}{uni bern}{
\begin{minipage}[b]{\textwidth}
\vspace{0.5ex}
\raggedright
\vspace{3.5ex}
{\insertframetitle\par}
{\usebeamerfont{framesubtitle}\usebeamercolor*{framesubtitle}\insertframesubtitle}
\end{minipage}
}


% set bullets

\defbeamertemplate*{itemize item}{uni bern}{$\bullet$}
\defbeamertemplate*{itemize subitem}{uni bern}{$\bullet$}
\setbeamersize{text margin left=4ex}
\setbeamersize{text margin right=4ex}



\mode<all>

\makeatother


\usepackage{graphicx}
\usepackage{hyperref} % allows clickable urls
\usepackage{tikz}
\usepackage{listings} % show code

\usepackage{tikz}
\usetikzlibrary{snakes}
\usetikzlibrary{positioning}
\newlength\yearposx
\makeatletter
\def\blfootnote{\gdef\@thefnmark{}\@footnotetext}
\makeatother

\definecolor{lightgrey}{RGB}{245,245,245}

% slide numbering
\setbeamertemplate{footline}{
    \hfill
    \usebeamerfont{footline}%
    \usebeamercolor[fg]{footline}%
    \hspace{1em}%
    \insertframenumber/\inserttotalframenumber
}


% define title page
\title{text}
% begin document
\begin{document}


    

\frame{
    \frametitle{a}
}

\frame{
    \frametitle{a}
}

\frame{
    \frametitle{a}
}

\frame{
    \frametitle{a}
}
\end{document}

相关内容