到目前為止,我們的頁眉是下面這個頁面中的頁眉樣式。
我想做一些修改,把頁眉設置為導航欄加上一個自己的Logo,導航欄信息只在除了標題頁之外的其它頁面顯示。
使用的是如下的代碼。
\defbeamertemplate{headline}{NGEGHeadlineTemplate}
{%
\leavevmode%離開垂直模式
\settoheight{\@tempdimb}{\usebeamerfont*{headline}{頁眉}}%把頁眉字體的高度賦值給了變量\@tempdimb
\@tempdimb=2\@tempdimb
\pgfdeclareimage[height=1.\@tempdimb]{title_logo}{New-Tikzfile-white.eps}%定義了一個叫做title_logo的pgfimage,並指明了圖片的高度,它具體使用的是自己准備的一個叫做New-Tikzfile-white.eps圖片
\ifdim\@tempdimb>0pt%ifdim<dimen1><relation><dimen2>,比較兩個尺寸。這里的意思是,如果\@tempdimb大於0pt(也就等於是有頁眉),就執行下面的代碼
\begin{beamercolorbox}[wd=.9\paperwidth,ht=\@tempdimb]{section in head/foot}%開始一個beamercolorbox盒子,指定了盒子的長度和寬度,並且顏色指定為section in head/foot,也就是“頂邊或底邊導航條中的節標題”所使用的顏色。這個盒子里面放置導航條
\ifnum \the\value{page}>1%頁面大於1,也就是說不是標題頁
\vbox to\@tempdimb{\vfil \centerline{\insertsectionnavigationhorizontal{.5\textwidth}{\hskip0pt plus1filll}{\hskip0pt plus1filll}}\vfil}%構建一個高度為@tempdimb的垂直盒子,插入水平排列的導航條,導航條的水平寬度為0.5\textwidth,導航條左邊和右邊插入的空白為\hskip0pt plus1filll,導航條的上面和下面用空白來填充(通過\vfil命令來實現)
\fi
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.1\paperwidth,ht=\@tempdimb,center]{subsection in head/foot}%開始一個beamercolorbox盒子,指定了盒子的寬度和高度,內容居中,顏色指定為subsection in head/foot,也就是“頂邊或底邊導航條中的小節標題”所使用的顏色。這個盒子里面放置自己的Logo
\vbox to\@tempdimb{\vfil\pgfuseimage{title_logo}\vfil}%構建一個高度為@tempdimb的垂直盒子,在里面使用已經定義的圖片title_logo,圖片的上下用空白來填充
\end{beamercolorbox}%
\fi%結束if條件判斷
}
\setbeamertemplate{headline}[NGEGHeadlineTemplate]
最后出來的效果如下。