Beamer - 如何删除标题和框架标题之间的空格

Beamer - 如何删除标题和框架标题之间的空格

我正在尝试删除标题和框架标题之间的空格,如下图所示。

在此处输入图片描述

我的代码的相关部分是:

\documentclass[t]{beamer}
\useinnertheme{rectangles}
\usecolortheme{whale}

\usepackage{natbib, amsmath, bm, tikz, mathrsfs, tabularx, booktabs, csvsimple, siunitx, graphicx}
\usetikzlibrary{positioning, fit, arrows.meta, shapes, calc}

\setbeamertemplate{headline}{
\leavevmode%
  \begin{beamercolorbox}[wd=.15\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt]{palette primary}{\insertsectionhead}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.85\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt]{subsection in head/foot}{\insertsubsectionhead}
  \end{beamercolorbox}%
}

\setbeamertemplate{frametitle}{
\begin{beamercolorbox}[wd=\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt]{section in head/foot}{\insertframetitle}
\end{beamercolorbox}%
}

\setbeamertemplate{footline}{
  \begin{beamercolorbox}[wd=\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt, rightskip=10pt]{palette tertiary}{\insertshorttitle \hfill \insertframenumber/\inserttotalframenumber}
  \end{beamercolorbox}%
}

% get rid of nav bar
\setbeamertemplate{navigation symbols}{}

\title{Using Pricing Data and News Headlines to Predict the Direction of Stock Returns}
\author{Jack Dry}
\date{}

\begin{document}

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

\section{Introduction}
\begin{frame}{Outline}
\tableofcontents[currentsection]
\end{frame}

\end{document}

如果有人能帮助我,我将非常感激!

答案1

如果您查看 beamer 主题中 frametitles 的默认定义,您将看到,\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%如果 frametitle 具有背景颜色,它将删除行之间的空格。

\documentclass[t]{beamer}
\useinnertheme{rectangles}
\usecolortheme{whale}

\usepackage{natbib, amsmath, bm, tikz, mathrsfs, tabularx, booktabs, csvsimple, siunitx 
%graphicx
}
\usetikzlibrary{positioning, fit, arrows.meta, shapes, calc}

\setbeamertemplate{headline}{%
\leavevmode%
  \begin{beamercolorbox}[wd=.15\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt]{palette primary}%
    \insertsectionhead%
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.85\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt]{subsection in head/foot}%
    \insertsubsectionhead%
  \end{beamercolorbox}%
}

\setbeamertemplate{frametitle}{%
\ifbeamercolorempty[bg]{frametitle}{}{\nointerlineskip}%
\begin{beamercolorbox}[wd=\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt]{section in head/foot}%
    \insertframetitle%
\end{beamercolorbox}%
}

\setbeamertemplate{footline}{
  \begin{beamercolorbox}[wd=\paperwidth, ht=2.5ex, dp=1ex, leftskip=10pt, rightskip=10pt]{palette tertiary}{\insertshorttitle \hfill \insertframenumber/\inserttotalframenumber}
  \end{beamercolorbox}%
}

% get rid of nav bar
\setbeamertemplate{navigation symbols}{}

\title{Using Pricing Data and News Headlines to Predict the Direction of Stock Returns}
\author{Jack Dry}
\date{}

\begin{document}

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

\section{Introduction}
\begin{frame}{Outline}
\tableofcontents[currentsection]
\end{frame}

\end{document}

相关内容