Beamer制作演示文檔-4:設置標題頁的樣式


到目前為止,我建立了一個叫做NGEGTemplate.cls的文類文件,它現有的內容為:

\LoadClass{beamer}
\NeedsTeXFormat{LaTeX2e}%宏包所屬的Latex版本
\ProvidesClass{NGEGTemplate}[2020/08/14 My custom beamer class]

\RequirePackage{ctex}%中文支持

\useoutertheme{infolines}
\useinnertheme{rounded}
\usecolortheme{rose}
\usecolortheme{whale}


%% 在每個章節的前面顯示目錄提示
\AtBeginSection[]
{
	\begin{frame}{主要內容}
		\transfade%淡入淡出
		\tableofcontents[sectionstyle=show/shaded,subsectionstyle=show/shaded/hide]
		\addtocounter{framenumber}{-1}  %目錄頁不計算頁碼
	\end{frame}
}
%頁面大小設置
\input{pagesize}
%背景設置
\input{background}

我的main.tex文件的內容為:

\documentclass{NGEGTemplate}

\title{南宮二狗的Beamer模板}
\institute{Latex自學社}
\author{南宮二狗}
\begin{document}
	\transblindshorizontal%一個動畫效果
	\begin{frame}{}
		\transdissolve%溶化
		\maketitle
	\end{frame}
\end{document}

以上所生成的標題頁是下面的樣子
enter description here

我想把它改成組織和姓名在同一行,使用同樣的字體。同時不顯示日期。使用的代碼如下。

\defbeamertemplate{title page}{NGEGTitlePageTemplate}%定義一個叫做NGEGTitlePageTemplate的title page模板
{
%	\vbox{}
	\vfill%豎直方向空白填充,和下面的\vifll結合使用可以使它們之間的內容豎直居中
		\begin{beamercolorbox}[sep=8pt,center,rounded=true]{title}%使用一個彩色盒子環境,內容和邊界的距離設置為8pt,內容居中對齊,邊界拐角使用圓角。盒子的顏色使用title的顏色
			\usebeamerfont{title}\inserttitle\par%%插入標題內容,並對字體進行了設置
			\ifx\insertsubtitle\@empty%%\ifx的作用是比較兩個字符串是否相等,這里的作用是判斷是否有子標題,如果沒有,就什么也不做
			\else%%有子標題
				\vskip0.25em%%豎直跳過一段距離
				{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%%插入子標題,並設置了所使用的字體和前景顏色
			\fi%     
		\end{beamercolorbox}%
		\vskip2cm\par%%豎直跳過一段距離
		\begin{beamercolorbox}[sep=8pt,center]{institute}%使用一個彩色盒子環境,內容和邊界的距離設置為8pt,內容居中對齊。盒子的顏色使用institute的顏色
			\usebeamerfont{institute}\insertinstitute\hskip1cm\usebeamerfont{author}\insertauthor\par%插入機構名和作者名,之間水平間隔1cm,並設置使用institute的字體
		\end{beamercolorbox}
	\vfill
}
\setbeamertemplate{title page}[NGEGTitlePageTemplate]%使用這個叫做NGEGTitlePageTemplate的title page模板

命令\defbeamertemplate{title page}{template name}{template context}的作用是對標題頁定義一個模板,這個模板的名字叫做template name,它的樣式由template context里面的代碼來制定。
命令\setbeamertemplate{title page}[template name]的作用是把叫做template name的模板應用到標題頁上。

最終得到的樣式如下:
enter description here


免責聲明!

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



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