我正在尝试将 Powerpoint 模板移植到 beamer,并且尝试复制这种字体样式:
我在两个地方使用这种字体:
- 标题页。此文本是 beamercolorbox 中的一个段落(3 行)。我无法拆分段落,因为我使用的是 \inserttitle。但如果有必要,我可以使用 TikZ 节点。
- 框架标题。此文本仅占 TikZ 节点内的一行。
我试过:
我正在使用 pdflatex。
当前工作示例(没有任何类型的阴影):
演示文稿.tex
\documentclass{beamer}
\usepackage[utf8]{inputenc} % UTF8
\usetheme{ABS}
\title{This is a very long title that spans over several lines. It is very long, isn't it?}
\author{Mr. Me}
\institute{
Faculty of applied Internet\\
University of somewhere
}
\date{28 June 2016}
\begin{document}
\frame{\titlepage}
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents
\end{frame}
\section{Introduction}
\begin{frame}
\frametitle{This is the first slide}
%Content goes here
\end{frame}
\begin{frame}
\frametitle{This is the second slide}
\framesubtitle{A bit more information about this}
%More content goes here
\end{frame}
% etc
\end{document}
beamerthemeABS.sty
\mode<presentation>
% http://www.r-bloggers.com/create-your-own-beamer-template/
% https://tex.stackexchange.com/questions/146529/design-a-custom-beamer-theme-from-scratch
\mode<presentation>
\usepackage{tikz}
\usepackage{color}
\usetikzlibrary{shadows}
% Color definitions
\definecolor{green-abs}{RGB}{45, 137, 115}
\definecolor{light-green-abs}{RGB}{53, 159, 133}
\definecolor{light-blue-abs}{RGB}{208, 240, 245}
\definecolor{titlecolor-abs}{RGB}{255, 255, 255}
\definecolor{textcolor-abs}{RGB}{0, 0, 0}
% Color assignments
\setbeamercolor{frametitle}{fg = titlecolor-abs}
\setbeamercolor{title}{fg = titlecolor-abs}
\setbeamercolor{section in toc}{fg = textcolor-abs}
\setbeamercolor{section in toc shaded}{fg = textcolor-abs}
\setbeamercolor{item}{fg = textcolor-abs}
\setbeamercolor{subitem}{fg = textcolor-abs}
\setbeamercolor{subsubitem}{fg = textcolor-abs}
\setbeamercolor{description item}{fg = textcolor-abs}
\setbeamercolor{caption}{fg = textcolor-abs}
\setbeamercolor{caption name}{fg = textcolor-abs}
\setbeamercolor{normal text}{fg = textcolor-abs}
% Background
\setbeamertemplate{background canvas}{
\ifnum\c@framenumber=1
% First slide
\begin{tikzpicture}[remember picture, overlay]
\shade[outer color=green-abs, inner color=light-green-abs]
(current page.north east) rectangle (current page.south west);
\end{tikzpicture}
\else
% Other slides
\begin{tikzpicture}[remember picture, overlay]
\shade[top color=light-blue-abs, bottom color=white]
(current page.north east) rectangle (current page.south west);
\end{tikzpicture}
\fi
}
% Inner theme
\useinnertheme{rounded}
% Outer theme
\setbeamerfont{frametitle}{size = \Large}
\setbeamertemplate{frametitle}{
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\begin{tikzpicture}[remember picture, overlay]
\shade[outer color=green-abs, inner color=light-green-abs]
(0, 0) rectangle (\the\paperwidth, 1.55cm);
%%%%%%
% I'd like to set the style of frametitles
%%%%%%
\node[anchor = west, titlecolor-abs] at (0.5, 0.8)
{\usebeamerfont{frametitle}\insertframetitle};
\end{tikzpicture}
\end{beamercolorbox}
}
% Title
\setbeamerfont{title}{size = \huge}
\setbeamertemplate{title page}{
\vfill
\centering
\begin{beamercolorbox}[sep=8pt, center]{title}
%%%%%%
% I'd like to set the style of titles, which may be very long
%%%%%%
\usebeamerfont{title}\inserttitle\par
\end{beamercolorbox}
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center]{author}
\usebeamerfont{author}\insertauthor
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{institute}
\usebeamerfont{institute}\insertinstitute
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{date}
\usebeamerfont{date}\insertdate
\end{beamercolorbox}\vskip0.5em
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
%\endgroup
\vfill
}
\mode<all>
答案1
一个快速的方法是再次写标题,稍微偏移一点,颜色更深。以下示例使用背景色和黑色的混合\color{black!20!green-abs}
,比示例中显示的阴影稍微暗一些,但可以根据您的需要进行调整。
\setbeamertemplate{frametitle}{
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\begin{tikzpicture}[remember picture, overlay]
\shade[outer color=green-abs, inner color=light-green-abs]
(0, 0) rectangle (\the\paperwidth, 1.55cm);
%%%%%%
% I'd like to set the style of frametitles
%%%%%%
\node[anchor = west, titlecolor-abs] at (0.53, 0.77)
{\usebeamerfont{frametitle}\color{black!20!green-abs}\insertframetitle};
\node[anchor = west, titlecolor-abs] at (0.5, 0.8)
{\usebeamerfont{frametitle}\insertframetitle};
\end{tikzpicture}
\end{beamercolorbox}
}
编辑:
为了获得更平滑的阴影,可以堆叠更多不同色调的图层。在以下示例中,使用了 5 个图层来创建更平滑的阴影:
\setbeamertemplate{frametitle}{
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\begin{tikzpicture}[remember picture, overlay]
\shade[outer color=green-abs, inner color=light-green-abs]
(0, 0) rectangle (\the\paperwidth, 1.55cm);
%%%%%%
% I'd like to set the style of frametitles
%%%%%%
\foreach \x in {0,5,...,20}
\node[anchor = west, titlecolor-abs, xshift=\x*-0.002cm, yshift=\x*0.002cm] at (0.5, 0.8) {%
\usebeamerfont{frametitle}%
\color{black!\x!green-abs}%
\insertframetitle%
};
\node[anchor = west, titlecolor-abs] at (0.5-0.002*20, 0.8+0.002*20)
{\usebeamerfont{frametitle}\insertframetitle};
\end{tikzpicture}
\end{beamercolorbox}
}
答案2
我会完成samcarter 的回答我添加了一些修改:我将代码移到一个函数,并且加深了阴影。
功能:
\tikzset{
text shadow/.code args={[#1]#2at#3(#4,#5)#6}{
\pgfkeysalso{/tikz/.cd,#1}
\foreach \x in {0,10,...,40}{%
\node[#1, xshift=\x*-0.001cm, yshift=\x*0.001cm] at (#4,#5){%
\color{black!\x!green-abs}
#6
};
}
\node[#1] at (#4-0.001*40, #5+0.001*40){#6};
}
}
(tzset
示例来自这里)
框架标题:
\setbeamertemplate{frametitle}{
\begin{beamercolorbox}[wd=\paperwidth, ht=1.5cm]{frametitle}
\begin{tikzpicture}[remember picture, overlay]
\shade[outer color=green-abs, inner color=light-green-abs]
(0, 0) rectangle (\the\paperwidth, 1.55cm);
\node[text shadow={[anchor = west, titlecolor-abs] at (0.5, 0.8)
{\usebeamerfont{frametitle}\insertframetitle}}] {};
\end{tikzpicture}
\end{beamercolorbox}
}
封面:
\setbeamertemplate{title page}{
\vfill
\centering
\begin{beamercolorbox}[sep=25pt, center]{title}
\begin{tikzpicture}[remember picture, overlay]
\node[text shadow={[titlecolor-abs, text width=0.85\paperwidth, text centered] at (0, 0)
{\usebeamerfont{title}\inserttitle\par}}] {};
\end{tikzpicture}
\end{beamercolorbox}
\vskip1em\par
\begin{beamercolorbox}[sep=8pt,center]{author}
\usebeamerfont{author}\insertauthor
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{institute}
\usebeamerfont{institute}\insertinstitute
\end{beamercolorbox}
\begin{beamercolorbox}[sep=8pt,center]{date}
\usebeamerfont{date}\insertdate
\end{beamercolorbox}\vskip0.5em
{\usebeamercolor[fg]{titlegraphic}\inserttitlegraphic\par}
\vfill
}
这些是标题页的结果:
看起来真的很棒!!