从 Claudio Fiandrino 的回答开始(从头开始设计自定义 Beamer 主题),我正在尝试为我的论文展示创建自己的beamer
主题。我对它很满意,但我想解决一些问题:
- 在封面,我使用 设置了上边距和标题之间的距离
\vskip<..>cm
,但每次修改标题时我都必须更改它(例如,如果标题跨越两行,我必须减小它),以便标题的基线与代码中可以看到的“垂直蓝线”的末端对齐。有没有办法自动设置它? - 如果框架标题(和字幕)跨越两行,新行将不会像第一行(其缩进为
\SideMargin
)那样缩进;我尝试使用\parbox
,但无法使其正常工作。
我尝试尽可能地清理代码,以便仅显示导致这些问题的部分。标题页背景是一张图片: 标题页.png 定义主题的所有文件是:
beamercolorthemePOLIMI.sty
\mode<presentation>
% Colors
% Footer
\definecolor{POLIblue}{RGB}{0,51,102}
\definecolor{POLIblue1}{RGB}{26,72,118}
\definecolor{POLIblue2}{RGB}{49,91,132}
\definecolor{POLIblue3}{RGB}{111,140,169}
\definecolor{POLIblue4}{RGB}{154,175,195}
\definecolor{POLIblue5}{RGB}{168,187,203}
\definecolor{POLIblue6}{RGB}{159,178,198}
\definecolor{POLIblue7}{RGB}{148,170,191}
\definecolor{POLIblue8}{RGB}{102,133,163}
% Header
\definecolor{POLIblue9}{RGB}{177,202,226}
\definecolor{POLIblue10}{RGB}{103,154,204}
\definecolor{POLIblue11}{RGB}{2,53,102}
\definecolor{POLIblue12}{RGB}{181,186,194}
% Page number
\definecolor{POLIpage}{RGB}{2,62,109}
% Settings
\setbeamercolor*{title page header}{fg=POLIblue}
\setbeamercolor*{author}{fg=black}
\setbeamercolor*{date}{fg=POLIblue}
\setbeamercolor*{item}{fg=POLIblue}
\setbeamercolor*{frametitle}{fg=POLIblue}
\setbeamercolor*{framesubtitle}{fg=POLIblue1}
\setbeamercolor*{page number in head/foot}{fg=POLIpage}
\setbeamercolor*{author in head/foot}{fg=POLIblue}
\mode<all>
beamerinnerthemePOLIMI.sty
\mode<presentation>
\usetikzlibrary{positioning}
\newlength\SideMargin
\setlength\SideMargin{1cm}
\newlength\TopMargin
\setlength\TopMargin{1cm}
\newlength\ImageWidth
\setlength\ImageWidth{\dimexpr\the\paperwidth-2\SideMargin\relax}
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\ifnum\thepage=1\relax{%
% Title page background
\node[anchor=north west,inner sep=0pt,minimum size=0pt] at(\SideMargin,{\the\paperheight-\TopMargin}){\includegraphics[width=\ImageWidth]{TitlePage.png}};
%%%% VERTICAL BLU LINE - I would like to have the bottom of the title aligned with the end of this line
\draw[color=POLIblue,line width=0.5pt] (8.186,10)--node[pos=1,inner sep=0pt,minimum size=0pt](b){}(8.186,6);
}
\else{%
\fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
}
\fi
\end{tikzpicture}
}
\setbeamerfont{title}{size=\normalfont\Large,family={\fontfamily{phv}},series=\bfseries}
\setbeamerfont{author}{size=\normalfont\normalsize,family={\fontfamily{phv}}}
\setbeamerfont{date}{size=\normalfont\small,family={\fontfamily{phv}}}
% Title page
\defbeamertemplate*{title page}{POLIMI}[1][]
{
\vskip10.4cm% TITLE POSITIONING
\begin{beamercolorbox}[wd=25cm,leftskip=7.85cm,sep=8pt,#1]{title page header}
\usebeamerfont{title}\inserttitle\par%
\end{beamercolorbox}%
\vskip0.75cm%
\begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{author}
\usebeamerfont{author}\insertauthor%
\end{beamercolorbox}
\vskip1cm%
\begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{date}
\ifx\insertdate\@empty%
\else
\usebeamerfont{date}\insertdate%
\fi
\end{beamercolorbox}
\vfill
}
\mode<all>
beamerouterthemePOLIMI.sty
\mode<presentation>
\setbeamerfont{frametitle}{size=\normalfont\Large,family={\fontfamily{phv}},series=\bfseries}
\setbeamerfont{framesubtitle}{size=\normalfont\large,family={\fontfamily{phv}}}
\setbeamerfont{page number in head/foot}{size=\normalfont\normalsize,family={\fontfamily{phv}},series=\bfseries}
% Frame title
\defbeamertemplate*{frametitle}{POLIMI}[1][]
{
\vskip\TopMargin%
\begin{beamercolorbox}[wd=\paperwidth,ht=1cm]{frametitle}
\begin{tikzpicture}
\useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1.2);
% Rectangles, line and frame number
\fill[POLIblue9] (19.2,0.75) rectangle (20.2,1);
\fill[POLIblue10] (20.4,0.75) rectangle (21.4,1);
\fill[POLIblue11] (21.6,0.75) rectangle (\the\paperwidth-\SideMargin,1);
\draw[POLIblue12] (19.2,-0.45) -- node[pos=0.1,above=0.2cm](PageN){%
\begin{beamercolorbox}[wd=1cm,ht=1ex,dp=0ex,left]{page number in head/foot}%
\usebeamerfont{page number in head/foot}\insertframenumber{}%
\end{beamercolorbox}} (\the\paperwidth-\SideMargin,-0.45);
% FRAME TITLE AND SUBTITLE
\ifx\insertframesubtitle\@empty%
{\node[anchor=west] at (\SideMargin-1.25cm,0.25){%
\begin{beamercolorbox}[wd=0.7\paperwidth,ht=5ex,dp=1ex,left]{frametitle}%
\usebeamerfont{frametitle}\hskip\SideMargin\insertframetitle%
%\parbox[t]{\dimexpr0.9\paperwidth-1em\relax}{\insertsection}%
\end{beamercolorbox}};
}%
\else%
{\node[anchor=west] at (\SideMargin-1.25cm,0.6){%
\begin{beamercolorbox}[wd=0.7\paperwidth,ht=5ex,dp=1ex,left]{frametitle}%
\usebeamerfont{frametitle}\hskip\SideMargin\insertframetitle%
\end{beamercolorbox}};
\node[anchor=west] at (\SideMargin-1.25cm,-0.4){%
\begin{beamercolorbox}[wd=0.7\paperwidth,ht=5ex,dp=1ex,left]{framesubtitle}%
\usebeamerfont{framesubtitle}\hskip\SideMargin\insertframesubtitle%
\end{beamercolorbox}};%
}%
\fi
\end{tikzpicture}
\end{beamercolorbox}
\vskip10mm%
}
\mode<all>
beamerthemePOLIMI.sty
\mode<presentation>
%%%% Requirements
% Page layout
\RequirePackage{geometry}
% Tikz pictures
\RequirePackage{tikz}
% Font type
\usepackage[T1]{fontenc}
\RequirePackage{helvet}
% Justified text
\RequirePackage{ragged2e}
\justifying
% Settings
\geometry{paperwidth=254.0mm,
paperheight=190.5mm,
left=0mm,
right=0mm,
top=0mm,
bottom=0mm}
\setbeamersize{text margin left=15mm,text margin right=15mm}
% Themes
\useinnertheme{POLIMI}
\useoutertheme{POLIMI}
\usecolortheme{POLIMI}
\setbeamertemplate{navigation symbols}{}
\mode<all>
最后,展示这些问题的演示文件:
\documentclass[17pt]{beamer}
\let\Tiny=\tiny
\usepackage{lipsum}
\title{Title, that might span one or two lines (or even more)}
\date{Now}
\author[Me]{Me}
\usetheme{POLIMI}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{A quite long frame title that cannot be shortened}
\lipsum[1]
\end{frame}
\begin{frame}{Another quite long frame title that cannot be shortened}
\framesubtitle{The same might happen for the frame subtitle, if it's too long}
\lipsum[1]
\end{frame}
\end{document}
答案1
这只是您可以考虑的第一个想法。不要将垂直线固定为背景的一部分,而是在构建标题时绘制它。命令\rule
将完成这项工作。标题可以包含在底部对齐中\parbox
。
我beamerinnerthemePOLIMI.sty
按照这种方式修改了,结果如下
我认为类似方法\parbox
可以应用于常规帧的标题和副标题,但我还没有测试过。
修改的beamerinnerthemePOLIMI.sty
\mode<presentation>
\usetikzlibrary{positioning}
\newlength\SideMargin
\setlength\SideMargin{1cm}
\newlength\TopMargin
\setlength\TopMargin{1cm}
\newlength\ImageWidth
\setlength\ImageWidth{\dimexpr\the\paperwidth-2\SideMargin\relax}
\setbeamertemplate{background}{
\begin{tikzpicture}
\useasboundingbox (0,0) rectangle(\the\paperwidth,\the\paperheight);
\ifnum\thepage=1\relax{%
% Title page background
\node[anchor=north west,inner sep=0pt,minimum size=0pt] at(\SideMargin,{\the\paperheight-\TopMargin}){\includegraphics[width=\ImageWidth]{TitlePage.png}};
% %%%% VERTICAL BLU LINE - I would like to have the bottom of the title aligned with the end of this line
% \draw[color=POLIblue,line width=0.5pt] (8.186,10)--node[pos=1,inner sep=0pt,minimum size=0pt](b){}(8.186,6);
% }
% \else{%
% \fill[white,opacity=1] (0,0) rectangle(\the\paperwidth,\the\paperheight);
}
\fi
\end{tikzpicture}
}
\setbeamerfont{title}{size=\normalfont\Large,family={\fontfamily{phv}},series=\bfseries}
\setbeamerfont{author}{size=\normalfont\normalsize,family={\fontfamily{phv}}}
\setbeamerfont{date}{size=\normalfont\small,family={\fontfamily{phv}}}
% Title page
\defbeamertemplate*{title page}{POLIMI}[1][]
{
\vskip5.4cm% TITLE POSITIONING
\begin{beamercolorbox}[wd=25cm,leftskip=7.85cm,sep=8pt,#1]{title page header}
\rule{.5pt}{4cm}\ \usebeamerfont{title}\parbox[b]{15cm}{\inserttitle}\par%
\end{beamercolorbox}%
\vskip0.75cm%
\begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{author}
\usebeamerfont{author}\insertauthor%
\end{beamercolorbox}
\vskip1cm%
\begin{beamercolorbox}[wd=25cm,leftskip=8.5cm,#1]{date}
\ifx\insertdate\@empty%
\else
\usebeamerfont{date}\insertdate%
\fi
\end{beamercolorbox}
\vfill
}
\mode<all>