我正在尝试编写自定义 Beamer 主题,但在弄清楚如何管理标题页以允许任意分配作者或标题时遇到了麻烦。
我已经设法弄清楚如何将标题、日期和作者信息放置在相对位置,但文本必须具有一定数量的行数,才能使所有内容与显示框正确对齐(即,标题位于蓝色框的中心,作者和日期信息位于绿色框的中心)。如果标题多于或少于 2 行,则会破坏格式。如果作者跨越 2 行以上,则会破坏格式。我最终希望标题在蓝色区域内的特定边界框内调整大小,作者和日期在绿色框中的边界框内调整大小。
实现这一目标的最佳方法是什么?
我的 beamerinnerthemeUniversity.sty 文件包含以下内容:
\definecolor{UniversityGreen}{RGB}{0, 133, 66}
\definecolor{UniversityOrange}{RGB}{199, 91, 18}
\definecolor{UniversityBlue}{RGB}{0, 161, 222}
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=UniversityBlue] (0,2) rectangle (\the\paperwidth,\the\paperheight);
\fill[color=UniversityOrange] (0,0) rectangle(2.95,1.9);
\node[inner sep=0] at (1.475,0.95) {\includegraphics[width=.25\textwidth]{University_logo.pdf}};
\fill[color=UniversityGreen] (3.05,0) rectangle(\the\paperwidth,1.9);
\ifnum\thepage>1\relax%
\fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fi
\end{tikzpicture}
}
\defbeamertemplate*{title page}{university}[1][]
{
\vskip4cm%
\begin{beamercolorbox}[wd=12cm,leftskip=2cm,sep=8pt,#1]{title page header}
\usebeamerfont{title}\inserttitle\par%
\end{beamercolorbox}%
\vskip1.75cm%
\begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{author}
\usebeamerfont{author}\insertauthor%
\end{beamercolorbox}
\vskip0.2cm%
\begin{beamercolorbox}[wd=12cm,leftskip=3cm,#1]{date}
\usebeamerfont{author}\insertdate%
\end{beamercolorbox}
\vfill
}
\setbeamertemplate{items}[square]
\setbeamertemplate{sections/subsections in toc}[square]
\mode
<all>
下面是当所有内容都以两行标题和两个简称的作者排列时的输出示例:
\documentclass[xcolor={table}]{beamer}
\usepackage[T1]{fontenc}
\usetheme{default}
\RequirePackage{tikz}
\useinnertheme{University}
\begin{document}
\title[A Presentation of Great Import]{A Presentation of Great Import:\\Important discoveries in science}
\author{Bob Smith \and Sally Johnson}
\institute{State University}
\date{February 24, 2016}
\frame{\titlepage}
\end{document}
以下是标题较长、作者较多的溢出示例
\documentclass[xcolor={table}]{beamer}
\usepackage[T1]{fontenc}
\usetheme{default}
\RequirePackage{tikz}
\useinnertheme{University}
\begin{document}
\title[A Presentation of Great Import]{A Presentation of Great Import:\\Important discoveries in science\\and a further digression on important things}
\author{Bob Smith \and Sally Johnson \and Uma Thirugnanasampanthan}
\institute{State University}
\date{February 24, 2016}
\frame{\titlepage}
\end{document}
答案1
为了将文本保留在各自的框内,我将文本放在minipage
s 内,这意味着您可以通过 简单地控制对齐方式\begin{minipage}[c][.8\textheight][c]{\textwidth}
,在此示例中,文本垂直居中。
\documentclass{beamer}
\usepackage{tikz}
\definecolor{UniversityGreen}{RGB}{0, 133, 66}
\definecolor{UniversityOrange}{RGB}{199, 91, 18}
\definecolor{UniversityBlue}{RGB}{0, 161, 222}
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\fill[color=UniversityBlue] (0,2) rectangle (\the\paperwidth,\the\paperheight);
\fill[color=UniversityOrange] (0,0) rectangle(2.95,1.9);
\node[inner sep=0] at (1.475,0.95) {\includegraphics[width=.2\textwidth]{example-image}};
\fill[color=UniversityGreen] (3.05,0) rectangle(\the\paperwidth,1.9);
\end{tikzpicture}
}
\defbeamertemplate*{title page}{university}[1][]{%
\begin{minipage}[c][.8\textheight][c]{\textwidth}
\usebeamerfont{title}
\inserttitle\par
\end{minipage}
\vskip1pt
\hskip.2\paperwidth
\begin{minipage}[c][.2\textheight][c]{.75\textwidth}
\usebeamerfont{author}
\raggedright
\insertauthor\par
\insertdate\par
\end{minipage}
}
\setbeamertemplate{items}[square]
\setbeamertemplate{sections/subsections in toc}[square]
\mode
<all>
\title[A Presentation of Great Import]{A Presentation of Great Import:\\Important discoveries in science}
\author{Bob Smith \and Sally Johnson}
\institute{State University}
\date{February 24, 2016}
\begin{document}
\begin{frame}[plain]
\titlepage
\end{frame}
\title[A Presentation of Great Import]{A Presentation of Great Import:\\Important discoveries in science\\and a further digression on important things}
\author{Bob~Smith \and Sally~Johnson \and Uma~Thirugnanasampanthan}
\institute{State University}
\begin{frame}[plain]
\titlepage
\end{frame}
\end{document}