最基本的框架
\documentclass{beamer} \usepackage[english]{babel} %如果去掉,中英混合會出錯 \usepackage[noindent]{ctex} %可使用 \usepackage{CJK} \usepackage{beamerthemesplit} % Or whatever. Note that the encoding and the font should match. If T1 % does not look nice, try deleting the line with the fontenc. \usepackage[T1]{fontenc} \usepackage{times} \usetheme{Berkeley} \title{XXXX} \subtitle{XXXX} \author{Ofey} \institute{ School of Computer Science\\ Beijing Institute of Technology } % This is only inserted into the PDF information catalog. Can be left out. \subject{OOO} \keywords{OXOX} \begin{document} \begin{frame}{XXXX} A normal frame. \end{frame} \end{document}
上面代碼,便可以生成一夜的slides了,在我機器上測試是木有問題的。beamer中的frame有點相當於powerpoint中的一葉,要是想新建幾頁,再多加加個frame吧,也可以寫成
\frame { \frametitle{test} A normal frame. }
至於frame和整個slides也都有相應的subtitle可以設置,隨便看下文檔就ok。
多個作者多個單位
有時,slides可能有多個作者,並且屬於多個單位,會議論文作報告時,經常遇見此情況。如下代碼解決
\author[Author, Another] % (optional, use only with lots of authors) {F.~Author\inst{1} \and S.~Another\inst{2}} % - Give the names in the same order as the appear in the paper. % - Use the \inst{?} command only if the authors have different affiliation. \institute[Beijing Institute of Technology] % (optional, but mostly needed) { \inst{1} School of Computer Science\\ Beijing Institute of Technology \and \inst{2} Department of Theoretical Philosophy\\ University of Elsewhere } % - Use the \inst command only if there are several affiliations. % - Keep it simple, no one is interested in your street address.
institute中寫Email是可以直接識別出的,放心使用。至於經常出現的中括號可選項,用了乃就懂的~~
logo
有時,要插入個校徽神馬的,吐槽下學校官方竟然每個矢量校徽。。。
導言區加:
% If you have a file called "university-logo-filename.xxx", where xxx % is a graphic format that can be processed by latex or pdflatex, % resp., then you can add a logo as follows: % \pgfdeclareimage[height=0.5cm]{university-logo}{university-logo-filename} % \logo{\pgfuseimage{bitlogo}} \logo{\includegraphics[height=0.09\textwidth]{./pic/bitlogo.eps}} %這只是我的logo路徑
目錄(TOC)
LATEX生成目錄這類實在是拿手戲。最簡單的:
\begin{frame} \tableofcontents \end{frame}
有時,可能目錄太多,想分成兩欄,可以使用multicol包
% This environment allows switching between one and multicolumn format on the same page \usepackage{multicol} \begin{frame}{Outline} \begin{multicols}{2} \tableofcontents % You might wish to add the option [pausesections] \end{multicols} \end{frame}
有時,可能不想顯示subsection之類,亦或者只想限制指定的幾個section,如下:
\tableofcontents[hidesubsections,sections={<1-4>}] %顯示1-4section,不顯示subsection
\tableofcontents還有很多其他參數設置,詳見文檔。
若想在沒個章節前顯示下目錄提示,可以如下代碼:
\AtBeginSection[] { \begin{frame} \frametitle{Outline} \tableofcontents[currentsection,hideothersubsections] \end{frame} \addtocounter{framenumber}{-1} %目錄頁不計算頁碼 }
不過沒發現如何獲得當前section的數值,這樣我就可以自動在每張前插入目錄,且使當前目錄爲第一。
當然,還可以做成一個個顯示目錄的動畫效果,不過沒啥實際意義- -!
slides中的鏈接
有時想在slides中加入超鏈接,可以跳轉到指定的頁面,這個也是很easy的。
給欲跳轉到的frame加上label
\frame[label = XXX] { \frametitle{OOO} \framesubtitle{XXX} OOXX }
再在想加入超鏈接的地方加入:
\hyperlink{XXX}{\beamergotobutton{乃想顯示的文本}} %\beamergotobutton可以選其他的按鈕
顯示時間+頁數
這個根據不同的主題不一樣,比如Berkeley默認就木有,而CambridgeUS就是有的,可以自己在導言區加入:
\setbeamertemplate{footline}{% \leavevmode% \hbox{% \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}% \usebeamerfont{author in head/foot}\insertshortauthor \end{beamercolorbox}% \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}% \usebeamerfont{title in head/foot}\insertshorttitle \end{beamercolorbox}% \begin{beamercolorbox}[wd=.333333\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}% \usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em} \insertframenumber{} / \inserttotalframenumber\hspace*{2ex} \end{beamercolorbox}}% \vskip0pt% }
其實就是抄其他主題代碼。。。
頁腳顯示文本
有時希望在frame的左下角頁腳能顯示一些內容,並不是爲了報告時如何,只是給其他途徑看slides的人一點更詳盡的解釋、資料,但是又不想用腳註(腳註在beamer效果不咋的)。
% add text to beamer footline \makeatletter % add a macro that saves its argument \newcommand{\footlineextra}[1]{\gdef\insertfootlineextra{#1}} \newbox\footlineextrabox % add a beamer template that sets the saved argument in a box. % The * means that the beamer font and color "footline extra" are automatically added. \defbeamertemplate*{footline extra}{default}{ \begin{beamercolorbox}[ht=2.25ex,dp=1ex,leftskip=\Gm@lmargin]{footline extra} \insertfootlineextra % \par\vspace{2.5pt} \end{beamercolorbox} } \addtobeamertemplate{footline}{% % set the box with the extra footline material but make it add no vertical space \setbox\footlineextrabox=\vbox{\usebeamertemplate*{footline extra}} \vskip -\ht\footlineextrabox \vskip -\dp\footlineextrabox \box\footlineextrabox% } {} % patch \begin{frame} to reset the footline extra material \let\beamer@original@frame=\frame \def\frame{\gdef\insertfootlineextra{}\beamer@original@frame} \footlineextra{} \makeatother
使用很簡單:
\footlineextra{XXXX}
這個參照的這裏
效果如圖
參考文獻
LATEX最爽的幾點之一就是參考文獻的管理使用啊,畢設論文得用doc的淚奔T.T
一般用的比較多的是bibtex,首先,自己搞定bib文件,然後slides中加上一頁來放引用文獻
%一般的引用樣式只是[1]類,paper中這樣沒啥,slides這樣不夠友好 %apalike:美國心理學學會期刊樣式,顯示作者名+年份 \bibliographystyle{apalike} \bibliography{XXX} %引用的XXX.bib文件
此外,reference可能較多,slides一頁一般都不夠用,beamer是可以自動分成多頁的,如下:
% If there are too many of them to fit on the frame, % you must manually split them among additional frames or use the allowframebreaks option. \begin{frame}[allowframebreaks]{References} \scriptsize \bibliographystyle{apalike} \bibliography{XXX} \end{frame}
引用,自然是\cite{}命令了
表格
有時,需要畫一些表格,可能比較複雜,比如可能需要合併幾行,或者幾列,下面一個示例:
導言區加上
\usepackage{multirow}
% The \cline command draws horizontal lines across the columns specified, �ginning in column i and ending in column j, which are identified in the mandatory argument. % \cline{i-j} \begin{table} \begin{tabular}{c|c|c|c} \hline % \multicolumn{2}{c}{\backslashbox{Name}{Numer}} & \multicolumn{2}{c}{}\\ \hline \multirow{2}{*}{CleanEval} & \multirow{2}{*}{CleanEval-Eng} & training set & 60 \\ \cline{3-4} \multirow{2}{*}{} & \multirow{2}{*}{} & evaluation set & 864 \\ \hline \multirow{6}*{CETD} & NYTimes & \multicolumn{2}{c}{100} \\ \cline{2-4} \multirow{6}*{} & Yahoo! & \multicolumn{2}{c}{100} \\ \cline{2-4} \multirow{6}*{} & Wikipedia & \multicolumn{2}{c}{100} \\ \cline{2-4} \multirow{6}*{} & BBC & \multicolumn{2}{c}{100} \\ \cline{2-4} \multirow{6}*{} & Ars Technica & \multicolumn{2}{c}{100} \\ \cline{2-4} \multirow{6}*{} & Chaos & \multicolumn{2}{c}{200} \\ \hline \end{tabular} \end{table}
效果如圖
其中,\multirow{6}*{CETD} 6代表佔用6行,CETD是其內容,其實下面的\multirow{6}*{}是可以去掉的,只是爲了代碼排版更清晰
\multicolumn{2}{c}{100}值合併兩列,並且居中。
\cline的解釋見代碼註釋
至於有時候可能會想要斜線的效果,不過latex中表格斜線分割看上去不舒服,還是不推薦,尤其科技論文中,文檔直接明說不推薦
更多設置,詳見Tables
in LaTeX: packages and methods
sidebar
Berkeley主題中的sidebar默認顯示所有的subsection,並且在顯示對應的頁時,高亮相應的section。對此可以作一些自定義。
一般章節較多時,sidebar就很不友好了,顯示不全,間距還大,彆扭,只是取消顯示subsection,一句話搞定
\usetheme[hideallsubsections]{Berkeley}
一種更好的sidebar顯示方式:
% By default, the current entry of the table of contents in the sidebar will be highlighted by using a more vibrant color. % A good alternative is to highlight the current entry by using a different color for the background of the current point. % The color theme sidebartab installs the appropriate colors \usecolortheme{sidebartab}
圖表、算法編號
beamer彷彿默認是不顯示圖標標號的默認值是Figure:XXX
% show fig and table number \setbeamertemplate{caption}[numbered] % show theorems and example number \setbeamertemplate{theorems}[numbered]
字體大小
beamer中某人的一些項目字體太大,比如樣例example,可以在導言區自定義
\setbeamerfont{example}{size=\tiny} \setbeamerfont{algorithm}{size=\scriptsize}
Chaos
至於關於動畫之類的,其實更多的涉及到的是LATEX的畫圖,扯起來就太多了,不扯了,直接照着各文檔來吧。
一般這些畫圖包都有各式各樣的樣例供參考,比如:這裏,texexample也很不錯。
至於beamer更多東西,直接去文檔裏找吧,很詳細,見這裏
PS:最後,stackexchange是個好網站
轉發
http://ofey.me/2011/12/beamer使用筆記/
原文鏈接:http://blog.sina.com.cn/s/blog_9908653401010nh1.html