当 beamer 模板中的标题为空时进行垂直对齐

当 beamer 模板中的标题为空时进行垂直对齐

我正在使用 Beamer 的自定义模板。除其他事项外,我完全重写了标题模板。但是,当我使用没有标题的框架时,垂直对齐方式与其他带标题的幻灯片不同。令人惊讶的是,无论标题是一行还是两行,它都能很好地工作……这很难解释,但在下面的例子中很容易看出。请注意第三张幻灯片中的错误垂直对齐方式。有趣的部分在第 68 行。知道这里发生了什么吗?

\PassOptionsToPackage{draft}{graphicx}
\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{amsfonts}
\usepackage{cmbright}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\usepackage{gnuplot-lua-tikz}
\usepackage{environ}
\usepackage{ulem}
\usepackage{textpos}

\makeatletter
\patchcmd{\beamer@sectionintoc}{\vskip1.5em}{\vskip0.5em}{}{}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%TWO COLOURS OF THE TEMPLATE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{azul}{rgb}{0.603,0.733,0.833}
\definecolor{verde}{rgb}{0.647,0.663,0.2.7}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SETTING COLOURS IN SEVERAL ELEMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamercolor{frametitle}{fg=black}
\setbeamercolor{headline}{fg=black}
\setbeamercolor{footline}{fg=black}
\setbeamercolor{block body}{bg=azul}
\setbeamercolor{block title}{bg=verde,fg=black}
\setbeamercolor{item}{fg=verde}
\setbeamercolor{alerted text}{fg=Red}
\setbeamercolor{section in toc}{fg=azul}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SETTING ASPECT OF DIVERSE FRAME ELEMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useoutertheme[]{default}

\setbeamertemplate{section in toc}[circle]
\setbeamertemplate{subsection in toc}[square]
\setbeamertemplate{itemize item}{$\bullet$}
\setbeamertemplate{navigation symbols}{}
\setbeamercovered{invisible}
\setbeamertemplate{sections in toc}[ball]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SETTING THE FOOTLINE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{
  \hspace{.6cm}
  \vspace{.2cm}
  \tikz \fill [azul] (0,0) rectangle (11.4, 2pt);

  \parbox[c][0.8cm][t]{\textwidth}{\hspace{3em} \scriptsize\bf 17 November 2014 $\rangle$ J.J. G\'omez-Navarro $\rangle$ edit the footline in the preamble}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%THIS THEME DISCARDS THE TITLE IN THE SLIDES, AND USES HEADLINE INSTEAD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{frametitle}{}
\providecommand\insertframetitle{}
\setbeamertemplate{headline}{

  \hspace{1cm}
  \parbox[c][1.2cm][c]{.65\textwidth}{\raggedright{}\bf\Large\insertframetitle}

  \begin{textblock*}{100mm}(.8\textwidth,-1.0cm)
    \includegraphics[width=2.0cm]{logo.pdf}
  \end{textblock*}

  \vspace*{0.1cm}

  \hspace*{0.6cm}
  \tikz \fill [azul] (0,0) rectangle (9.0, 2pt);
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PRESENTATION  STARTS HERE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}


\begin{frame}{title}

  frame with title

\end{frame}



\begin{frame}{Very very long title with so much text it does not fit in one lines }

  frame frame frame

\end{frame}

\begin{frame}{ }

  frame frame frame

\end{frame}

\end{document}

答案1

如果在第三帧中删除{}(表示标题为空),您将看到相同的垂直对齐问题。这对我来说意味着需要提供输入。在这种情况下,{}\empty\phantom{text}就可以解决问题。

\begin{frame}{{}} or \begin{frame}{\empty} or \begin{frame}{\phantom{a}}

在此处输入图片描述 在此处输入图片描述

代码

\PassOptionsToPackage{draft}{graphicx}
\documentclass[xcolor=dvipsnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tikz}
\usepackage{amsfonts}
\usepackage{cmbright}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\usepackage{gnuplot-lua-tikz}
\usepackage{environ}
\usepackage{ulem}
\usepackage{textpos}

\makeatletter
\patchcmd{\beamer@sectionintoc}{\vskip1.5em}{\vskip0.5em}{}{}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%TWO COLOURS OF THE TEMPLATE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{azul}{rgb}{0.603,0.733,0.833}
\definecolor{verde}{rgb}{0.647,0.663,0.2.7}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SETTING COLOURS IN SEVERAL ELEMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamercolor{frametitle}{fg=black}
\setbeamercolor{headline}{fg=black}
\setbeamercolor{footline}{fg=black}
\setbeamercolor{block body}{bg=azul}
\setbeamercolor{block title}{bg=verde,fg=black}
\setbeamercolor{item}{fg=verde}
\setbeamercolor{alerted text}{fg=Red}
\setbeamercolor{section in toc}{fg=azul}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SETTING ASPECT OF DIVERSE FRAME ELEMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\useoutertheme[]{default}

\setbeamertemplate{section in toc}[circle]
\setbeamertemplate{subsection in toc}[square]
\setbeamertemplate{itemize item}{$\bullet$}
\setbeamertemplate{navigation symbols}{}
\setbeamercovered{invisible}
\setbeamertemplate{sections in toc}[ball]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%SETTING THE FOOTLINE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{footline}{
  \hspace{.6cm}
  \vspace{.2cm}
  \tikz \fill [azul] (0,0) rectangle (11.4, 2pt);

  \parbox[c][0.8cm][t]{\textwidth}{\hspace{3em} \scriptsize\bf 17 November 2014 $\rangle$ J.J. G\'omez-Navarro $\rangle$ edit the footline in the preamble}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%THIS THEME DISCARDS THE TITLE IN THE SLIDES, AND USES HEADLINE INSTEAD
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setbeamertemplate{frametitle}{}
\providecommand\insertframetitle{}
\setbeamertemplate{headline}{

  \hspace{1cm}
  \parbox[c][1.2cm][c]{.65\textwidth}{\raggedright{}\bf\Large\insertframetitle}

  \begin{textblock*}{100mm}(.8\textwidth,-1.0cm)
    \includegraphics[width=2.0cm]{logo.pdf}
  \end{textblock*}

  \vspace*{0.1cm}

  \hspace*{0.6cm}
  \tikz \fill [azul] (0,0) rectangle (9.0, 2pt);
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PRESENTATION  STARTS HERE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}


\begin{frame}{title}

  frame with title

\end{frame}



\begin{frame}{Very very long title with so much text it does not fit in one lines }

  frame frame frame

\end{frame}

\begin{frame}{ }

  frame frame frame

\end{frame}

\end{document}

相关内容