Beamer制作演示文檔-5:設置目錄頁樣式


現在,通過代碼\begin{frame}{主要內容} \transfade%淡入淡出 \tableofcontents \end{frame}生成的目錄頁是下面這樣的形式
enter description here

經驗豐富的老專家說,你這怎么只有文字?這不行,你得加文本框,加陰影,你得有效果!
那就試試吧。使用了如下的代碼

\RequirePackage{tikz}%用tikz包來畫背景和陰影
\usetikzlibrary{calc}%,shapes.geometric,shapes.callouts}%需要用到的tikz庫,calc用於坐標的計算
\newlength{\boxw}%盒子的寬度
\newlength{\boxh}%盒子的高度
\newlength{\boxroundness}%盒子的圓角大小
\newlength{\boxshadowsize}%陰影到盒子之間的距離
\newlength{\tmpa}%臨時長度
\setlength{\boxshadowsize}{6pt}%設置陰影到盒子之間的距離
\setlength{\boxroundness}{3pt}%設置盒子的圓角大小

\newsavebox{\shadowblockbox}%新建一個盒子環境
\newenvironment{shadowblock}[1]%這個是自定義的一個陰影盒子,在這里用來放目錄的內容。當然,在其它的地方就可以用來放其它的東西。這個盒子會接收一個參數來指定盒子的寬度
	{%
		\begin{lrbox}{\shadowblockbox}%%
			\begin{minipage}{#1}%%
	}%
	{%
		\end{minipage}%
		\end{lrbox}%
		\settowidth{\boxw}{\usebox{\shadowblockbox}}%
		\settodepth{\tmpa}{\usebox{\shadowblockbox}}%
		\settoheight{\boxh}{\usebox{\shadowblockbox}}%
		\addtolength{\boxh}{\tmpa}%
		\addtolength{\boxh}{2\boxroundness}%
		\addtolength{\boxw}{2\boxroundness}%
		\setlength{\boxw}{1.2\boxw}%
		\setlength{\boxh}{1.2\boxh}%
		\setlength{\tmpa}{1.2\tmpa}%
		\begin{tikzpicture}%畫背景
			\usebeamercolor{section number projected}
			\foreach \x in {0,.05,...,1}%畫陰影,每次改變畫的范圍,從而實現濃淡的漸變
			{%
				\fill[xshift=\boxshadowsize -1pt,yshift=-\boxshadowsize + 1pt,black,opacity=.04,rounded corners=\boxroundness](\x*\boxshadowsize,\x*\boxshadowsize) rectangle (\boxw -\x*\boxshadowsize,\boxh-\x*\boxshadowsize);
			};%
			\filldraw[inner color=fg,outer color=Grey0,draw=black!50,rounded corners=\boxroundness](0,0) rectangle (\boxw,\boxh);%畫出位於陰影前面的盒子
			\node[xshift=3\boxroundness ,yshift=2\boxroundness,inner sep=0pt,outer sep=0pt,anchor=south west](contents) at (0,0) {\usebox{\shadowblockbox}};%放上目錄的內容
			\CTEXnumber{\cna}{\inserttocsectionnumber}%把目錄編號改為中文形式
			\node[circle,inner color=fg,outer color=Grey0,minimum size=\boxh,inner sep=0pt,anchor=center,left of= contents,node distance = 0.7\boxw] {\cna};%放上目錄的編號
		\end{tikzpicture}
	}%


\defbeamertemplate{section in toc}{NGEGTOC}{
	

	\begin{center}
		\begin{shadowblock}{4cm}%
			\inserttocsection%
		\end{shadowblock}%
	\end{center}
}
\setbeamertemplate{section in toc}[NGEGTOC]

出現的是下面的效果
enter description here


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM