我想创建某个部分页面。但我还有 2 个问题。来自另一个问题为 Beamer 创建精美的章节页面我可以创建基础。
\documentclass[svgnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,shadings}
\tikzset{section number/.style={
inner sep=0pt,
draw=none,
},
section/.style={
inner sep=0pt,
draw=none,
text width=\the\dimexpr\paperwidth-3.8em\relax,
text=blue,
align=left
},
subsection/.style={
inner sep=0pt,
draw=none,
text width=\the\dimexpr\paperwidth-3.8em\relax,
text=gray,
align=left
}
}
\makeatletter
\def\sectionsubtitle#1{\gdef\@sectionsubtitle{#1}}
\AtBeginSection[]{%
\begingroup
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[gray!30] (current page.north west) rectangle (current page.south east);
\end{tikzpicture}
}
\begin{frame}
\begin{beamercolorbox}[wd=\paperwidth,ht=1cm]{}
\begin{tikzpicture}
\useasboundingbox[fill=white](0,0) rectangle(\the\paperwidth,1);
\shade [left color=gray,right color=white] (0,0) rectangle (\the\paperwidth,0.02);
\end{tikzpicture}
\end{beamercolorbox}
\begin{tikzpicture}[remember picture,overlay]
\node[section,anchor=east] at (current page.east) (title)
{\hfill\parbox[c][3.5em][c]{\the\dimexpr\paperwidth-4.2em\relax}{\fontsize{20}{20}\selectfont\insertsectionhead}\hfill};
\node[subsection,below= 2pt of title] (subtitle)
{\hfill\parbox[c][2em][c]{\the\dimexpr\paperwidth-4.2em\relax}{\@sectionsubtitle}\hfill};
\end{tikzpicture}
\end{frame}
\gdef\@sectionsubtitle{}
\endgroup
}
\makeatother
\begin{document}
\sectionsubtitle{Test Subtitle One}
\section{Test Section One}
\begin{frame}
Test Frame
\end{frame}
\sectionsubtitle{Test Subtitle Two}
\section{Test Section Two}
\begin{frame}
Test Frame
\end{frame}
\end{document}
我的问题是: - 将两个文本放在中间并居中。 - 将白色矩形移动到框架顶部而不是中间。不知何故,将其进一步向上移动不起作用。
答案1
这是您脚本的修改版本。我相信如果您开始使用tikzpicture
s,请完全使用它们,并且不要尝试与 混合beamercolorboxes
,否则会把一切都搞乱 :)。
\documentclass[svgnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,shadings}
\tikzset{section number/.style={
inner sep=0pt,
draw=none,
},
section/.style={
inner sep=0pt,
draw=none,
%text width=\the\dimexpr\paperwidth-3.8em\relax,
text=blue,
align=center
},
subsection/.style={
inner sep=0pt,
draw=none,
%text width=\the\dimexpr\paperwidth-3.8em\relax,
text=gray,
align=center
}
}
\makeatletter
\def\sectionsubtitle#1{\gdef\@sectionsubtitle{#1}}
\AtBeginSection[]{%
\begingroup
% Lighter, beamer native version
\setbeamercolor{background canvas}{bg=gray!30}
%
\begin{frame}
\begin{tikzpicture}[remember picture,overlay]
\coordinate[yshift=-10mm] (rectsouthwest) at (current page.north west);
\coordinate[yshift=-10mm] (rectsoutheast) at (current page.north east);
\fill[white] (current page.north west) rectangle (rectsoutheast);
\shade [left color=gray,right color=white] (rectsouthwest) rectangle +(\paperwidth,-0.02);
\node[section,anchor=center] at (current page.center) (title) {\fontsize{20}{20}\selectfont\insertsectionhead};
\node[subsection,below=5mm of title] (subtitle) {\@sectionsubtitle};
\end{tikzpicture}
\end{frame}
\gdef\@sectionsubtitle{}
\endgroup
}
\makeatother
\begin{document}
\sectionsubtitle{Test Subtitle One}
\section{Test Section One}
\begin{frame}
Test Frame
\end{frame}
\sectionsubtitle{Test Subtitle Two}
\section{Test Section Two}
\begin{frame}
Test Frame
\end{frame}
\end{document}