我目前正在努力创建看起来很花哨的部分页面以Beamer
实现以下布局:
根据我对匹配目录的疑问(适合 Beamer 的精美目录) 我想出了以下代码,它看起来不错,但确实与给定的布局非常相似。有什么想法可以改进代码吗?
\documentclass[svgnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\pgfdeclarehorizontalshading{section shading}{2cm}{
color(0cm)=(LightSlateGrey!15);
color(3cm)=(LightSlateGrey)
}
\pgfdeclarehorizontalshading{subsection shading}{2cm}{
color(0cm)=(red!15);
color(1cm)=(red);
color(3cm)=(green)
}
\usepackage{tikz}
\tikzset{section number/.style={
draw=none,
rectangle,
left color=gray!40,
right color=gray!20!black,
minimum size=3.5em,
text=white,
},
section/.style={
draw=none,
rectangle,
shading=section shading,
minimum height=3.5em,
minimum width=0.9\textwidth,
text width=0.9\textwidth,
text=black,
align=left
},
subsection/.style={
draw=none,
rectangle,
shading=subsection shading,
minimum height=2em,
minimum width=0.9\textwidth,
text width=0.9\textwidth,
text=black,
align=left
}
}
\begin{document}
\frame{
\begin{tabular}{p{1.2cm}p{9cm}}
\tikz[baseline=-0.5ex]\node[section number]{\bfseries\Large 123}; & \tikz[baseline=-0.5ex]\node[section]{\bfseries\large fxdfsdf}; \\ & \\
& \tikz[baseline=-0.5ex]\node[subsection]{\bfseries fxdfsdf};
\end{tabular}
}
\end{document}
答案1
这是一种可能性;使用 自动创建部分框架\AtBeginSection
。我使用了您的颜色和阴影,但您可以轻松更改它们(当然,您可以根据需要随意进行任何其他更改):
\documentclass[svgnames]{beamer}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,shadings}
\pgfdeclarehorizontalshading{section shading}{2cm}{
color(0cm)=(LightSlateGrey!15);
color(3cm)=(LightSlateGrey)
}
\pgfdeclarehorizontalshading{subsection shading}{2cm}{
color(0cm)=(red!15);
color(1cm)=(red);
color(3cm)=(green)
}
\tikzset{section number/.style={
inner sep=0pt,
draw=none,
rectangle,
left color=gray!40,
right color=gray!20!black,
minimum size=3.5em,
text=white,
text width=3.5em,
align=center
},
section/.style={
inner sep=0pt,
draw=none,
rectangle,
shading=section shading,
minimum height=3.5em,
minimum width=0.9\textwidth,
text width=\the\dimexpr\paperwidth-3.8em\relax,
text=black,
align=left
},
subsection/.style={
inner sep=0pt,
draw=none,
rectangle,
shading=subsection shading,
minimum height=2em,
minimum width=0.9\textwidth,
text width=\the\dimexpr\paperwidth-3.8em\relax,
text=black,
align=left
}
}
\makeatletter
\def\sectionsubtitle#1{\gdef\@sectionsubtitle{#1}}
\AtBeginSection[]{%
\begingroup
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay]
\fill[gray!10] (current page.north west) rectangle (current page.south east);
\fill[left color=red!40,right color=green!15]
( $ (current page.north west) + (0pt,-80pt) $ ) --
( $ (current page.north west) + (80pt,0pt) $ ) --
( $ (current page.north west) + (300pt,0pt) $ ) --
( $ (current page.north west) + (0pt,-300pt) $ ) --
cycle;
\fill[left color=LightSlateGrey!40,right color=LightSlateGrey!05]
( $ (current page.north west) + (300pt,0pt) $ ) --
( $ (current page.north west) + (500pt,0pt) $ ) --
( $ (current page.north west) + (0pt,-500pt) $ ) --
( $ (current page.north west) + (0pt,-300pt) $ ) --
cycle;
\end{tikzpicture}
}
\begin{frame}
\begin{tikzpicture}[remember picture,overlay]
\node[section number,anchor=west] at (current page.west) {\fontsize{30}{36}\selectfont\two@digits\thesection};
\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}
\sectionsubtitle
您所要做的就是在每个\section
命令前使用。