![Beamer - 如何删除标题和框架标题之间的空格](https://linux22.com/image/393337/Beamer%20-%20%E5%A6%82%E4%BD%95%E5%88%A0%E9%99%A4%E6%A0%87%E9%A2%98%E5%92%8C%E6%A1%86%E6%9E%B6%E6%A0%87%E9%A2%98%E4%B9%8B%E9%97%B4%E7%9A%84%E7%A9%BA%E6%A0%BC.png)
我正在尝试删除标题和框架标题之间的空格,如下图所示。
我的代码的相关部分是:
\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}