![Beamer:垂直居中幻灯片内容](https://linux22.com/image/301621/Beamer%EF%BC%9A%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%E5%B9%BB%E7%81%AF%E7%89%87%E5%86%85%E5%AE%B9.png)
我正在尝试制作测验幻灯片。在轮次之间,我想放置一张空白幻灯片,其中只有该轮次的标题,垂直居中。标题幻灯片也应垂直居中。
因为默认幻灯片(问题)将回合和问题编号显示为脚注,所以我定义了一个空白幻灯片命令:
% Frame without footline.
\newcommand{\blankframe}[1]{
{%
\setbeamertemplate{footline}{}
\begin{frame}
\begin{center}
#1
\end{center}
\end{frame}
}
}
我使用它来创建标题幻灯片,如下所示:
\blankframe{
{\huge My Quiz Title}
\vfill
{\scriptsize 2014}
}
新一轮:
\newcommand{\round}[2]{
\stepcounter{roundCounter}
\stepcounter{questionCounter}
\renewcommand{\currentRoundName}{#1}
\renewcommand{\currentRoundQuestions}{#2}
\blankframe{
{\huge #1}
}
}
但结果并不是完全垂直居中,而是稍微向顶部倾斜:
有人知道这是怎么回事吗?可能是因为 frametitle 为空,我该如何修复?
提前致谢!
这是一个完整的工作示例:
\documentclass[xelatex]{beamer}
\usepackage[quiet]{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage{xcolor}
\setbeamerfont{question}{size*={14}{1.4em}}
\setbeamertemplate{frametitle}{}
\setbeamertemplate{navigation symbols}{}
\newcounter{roundCounter}
\newcounter{questionCounter}[roundCounter]
\newcommand{\currentRoundName}{}
\newcommand{\currentRoundQuestions}{0}
% Start a new round with 2 arguments:
% #1 Round name
% #2 Number of questions in this round.
\newcommand{\round}[2]{
\stepcounter{roundCounter}
\stepcounter{questionCounter}
\renewcommand{\currentRoundName}{#1}
\renewcommand{\currentRoundQuestions}{#2}
\blankframe{
{\huge #1}
}
}
% Frame without footline.
\newcommand{\blankframe}[1]{
{%
\setbeamertemplate{footline}{}
\begin{frame}
\begin{center}
#1
\end{center}
\end{frame}
}
}
\begin{document}
\blankframe{
{\huge My Quiz Title}
\vfill
{\scriptsize 2014}
}
\round{Warm-up round}{10}
\end{document}
答案1
除了我在我的评论中提到的标题框之外,在 的定义中\vfill
添加更多 s 也可以实现更好的居中效果。\vfill
\blankframe
\documentclass[xelatex]{beamer}
\usepackage[quiet]{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{graphicx}
\usepackage{xcolor}
\setbeamerfont{question}{size*={14}{1.4em}}
\setbeamertemplate{frametitle}{}
\setbeamertemplate{navigation symbols}{}
\newcounter{roundCounter}
\newcounter{questionCounter}[roundCounter]
\newcommand{\currentRoundName}{}
\newcommand{\currentRoundQuestions}{0}
% Start a new round with 2 arguments:
% #1 Round name
% #2 Number of questions in this round.
\newcommand{\round}[2]{
\stepcounter{roundCounter}
\stepcounter{questionCounter}
\renewcommand{\currentRoundName}{#1}
\renewcommand{\currentRoundQuestions}{#2}
\blankframe{
{\huge #1}
}
}
% Frame without footline.
\newcommand{\blankframe}[1]{
{%
\setbeamertemplate{footline}{}
\begin{frame}
\vfill\vfill\centering#1\vfill\vfill
\end{frame}
}
}
\begin{document}
\blankframe{
{\vfill\huge My Quiz Title}\vfill
{\scriptsize 2014}
}
\round{Warm-up round}{10}
\end{document}