LaTeX/簡報
LaTeX 可用於建立簡報。有幾個包可用於此任務,例如- Powerdot、Prosper 、Seminar 等,但是 Beamer 包 是最廣泛使用的。
需要注意的是,Latex 以 PDF 格式生成簡報,可以使用某些 PDF 閱讀器(例如 Okular、Evince 或 Adobe Reader)以全屏模式檢視。如果您想在簡報中導航,可以使用右下角幾乎不可見的連結,而無需退出全屏模式。
beamer 包隨大多數 LaTeX 發行版提供,但也可以從 CTAN 獲得。如果您使用 MikTeX,您只需包含 beamer 包並讓 LaTeX 自動下載所有需要的包。 文件 詳細解釋了這些功能。您也可以檢視 PracTex 文章 Beamer by Example.[1]
beamer 包還載入了許多有用的包,包括 xcolors、hyperref 等。下面顯示了一個入門示例及其輸出。
在上面的程式碼中,Beamer 包透過標頭中的 \documentclass{beamer} 命令載入。然後可以指定通常的標頭資訊。在 Beamer 簡報中,幀等同於幻燈片(在 MS Office 中使用)。幀使用環境 \begin{frame} ...... \end{frame} 定義。 \frametitle{} 命令指定每個幻燈片的標題。幀標題和副標題也可以透過環境傳遞,如下所示。
\begin{frame}{Title of frame}{subtitle of frame}
...
\end{frame}
通常的環境(itemize、enumerate、equation 等)可以使用。在幀內,您可以使用 block、theorem、proof 等環境。此外,\maketitle 可用於建立標題頁,如果設定了 title 和 author。
標題頁是第一頁,您可以在其中插入以下資訊
- 標題和副標題(可選)- 使用
\title和\subtitle命令,或使用\title[短標題(可選)]{長標題}{副標題(可選)} - 作者姓名- 使用
\author{}命令。 - 機構名稱- 使用
\institute命令。請注意\inst{1}和\inst{2}命令的使用,用於將作者與其各自的機構關聯起來。 - 簡報的日期和地點- 可以使用
\date[短日期(可選)]{長日期}命令插入。 - 機構徽標等。
需要注意的是,方括號中的資訊,即 [ ] 是可選的。
重要的是在文件中包含 \maketitle 命令(如上面的程式碼所示)以建立標題幀。\maketitle 和 \titlepage 命令是等效的。
目錄(突出顯示當前部分)由以下內容顯示
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents[currentsection]
\end{frame}
這可以在每個部分的開頭自動完成,在序言中使用以下程式碼
\AtBeginSection[]
{
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents[currentsection]
\end{frame}
}
或用於子部分
\AtBeginSubsection[]
{
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents[currentsection,currentsubsection]
\end{frame}
}
與所有其他 LaTeX 檔案一樣,可以使用以下內容來構建文件
\section[Section]{My section}
\subsection[Subsection]{My subsection}
\subsubsection[Subsubsection]{My subsubsection}
這些命令必須放在幀之前和之間。它們將使用方括號中的引數修改目錄。可選引數將在幻燈片的標題導航中顯示,具體取決於使用的主題。您可以使用 \sectionpage 宏為宣告的部分生成一個分隔幻燈片,例如
\begin{frame}\sectionpage\end{frame}
以下示例顯示了一個包含兩個條目的手動製作的參考文獻幻燈片
\begin{frame}[allowframebreaks]
\frametitle<presentation>{Further Reading}
\begin{thebibliography}{10}
\beamertemplatebookbibitems
\bibitem{Autor1990}
A.~Autor.
\newblock {\em Introduction to Giving Presentations}.
\newblock Klein-Verlag, 1990.
\beamertemplatearticlebibitems
\bibitem{Jemand2000}
S.~Jemand.
\newblock On this and that.
\newblock {\em Journal of This and That}, 2(1):50--100, 2000.
\end{thebibliography}
\end{frame}
隨著參考文獻列表的增長,參考文獻幻燈片將透過使用allowframebreaks選項分成兩張幻燈片,依此類推。在向相關的bibitem節新增“可選”標籤後,可以引用各個專案。引用呼叫只是\cite。Beamer 還支援對參考文獻呈現方式的有限定製(參見手冊)。
不同型別的引用作品用一個小符號(例如,一本書、一篇文章等)來表示。該符號由命令beamertemplatebookbibitems和 beamertemplatearticlebibitems 設定。也可以直接使用setbeamertemplate,如下所示
\begin{frame}[allowframebreaks]
\frametitle<presentation>{Further Reading}
\begin{thebibliography}{10}
\setbeamertemplate{bibliography item}[book]
\bibitem{Autor1990}
A.~Autor.
\newblock {\em Introduction to Giving Presentations}.
\newblock Klein-Verlag, 1990.
\setbeamertemplate{bibliography item}[article]
\bibitem{Jemand2000}
S.~Jemand.
\newblock On this and that.
\newblock {\em Journal of This and That}, 2(1):50--100, 2000.
\end{thebibliography}
\end{frame}
除了 book 和 article 之外,其他可能的參考文獻型別還包括例如 online 、 triangle 和 text 。也可以透過包含圖形來擁有使用者定義的參考文獻專案。
如果想讓完整參考文獻作為腳註出現,請使用 biblatex 包中的\footfullcite。例如,可以使用
\documentclass[10pt,handout,english]{beamer}
\usepackage[english]{babel}
\usepackage[backend=biber,style=numeric-comp,sorting=none]{biblatex}
\addbibresource{biblio.bib}
\begin{frame}
\frametitle{Title}
A reference~\footfullcite{ref_bib}, with ref_bib an item of the .bib file.
\end{frame}
主題
[edit | edit source]Beamer 提供兩種方式來定義主題 - 1) 使用內建主題,2) 使用使用者定義主題。
內建解決方案
[edit | edit source]Beamer 有多個內建主題,可以透過在序言中指定它們的“名稱”和它們的“顏色”來使用。這個主題矩陣包含了Beamer中包含的各種主題和顏色組合。有關更多自定義選項,請檢視您beamer分發版中包含的官方文件,尤其是更改外觀部分。
\usetheme{Warsaw}
\usecolortheme{beaver}
主題的完整列表是
|
|
|
|
|
|
顏色主題的完整列表是
|
|
|
使用者定義的主題
[edit | edit source]首先,您可以指定outertheme,它定義每張幻燈片的頁首和頁尾。
\useoutertheme{infolines}
\useinnertheme{rectangles}
以下是所有可用外部和內部主題的列表
| 外部主題列表 | 內部主題列表 | |||||
| infolines | shadow | smoothbars | split | rectangles | inmargin | |
| miniframes | sidebar | smoothtree | tree | circles | rounded | |
您可以定義每個元素的顏色
\setbeamercolor{alerted text}{fg=orange}
\setbeamercolor{background canvas}{bg=white}
\setbeamercolor{block body alerted}{bg=normal text.bg!90!black}
\setbeamercolor{block body}{bg=normal text.bg!90!black}
\setbeamercolor{block body example}{bg=normal text.bg!90!black}
\setbeamercolor{block title alerted}{use={normal text,alerted text},fg=alerted text.fg!75!normal text.fg,bg=normal text.bg!75!black}
\setbeamercolor{block title}{bg=blue}
\setbeamercolor{block title example}{use={normal text,example text},fg=example text.fg!75!normal text.fg,bg=normal text.bg!75!black}
\setbeamercolor{fine separation line}{}
\setbeamercolor{frametitle}{fg=brown}
\setbeamercolor{item projected}{fg=black}
\setbeamercolor{normal text}{bg=black,fg=yellow}
\setbeamercolor{palette sidebar primary}{use=normal text,fg=normal text.fg}
\setbeamercolor{palette sidebar quaternary}{use=structure,fg=structure.fg}
\setbeamercolor{palette sidebar secondary}{use=structure,fg=structure.fg}
\setbeamercolor{palette sidebar tertiary}{use=normal text,fg=normal text.fg}
\setbeamercolor{section in sidebar}{fg=brown}
\setbeamercolor{section in sidebar shaded}{fg=grey}
\setbeamercolor{separation line}{}
\setbeamercolor{sidebar}{bg=red}
\setbeamercolor{sidebar}{parent=palette primary}
\setbeamercolor{structure}{bg=black, fg=green}
\setbeamercolor{subsection in sidebar}{fg=brown}
\setbeamercolor{subsection in sidebar shaded}{fg=grey}
\setbeamercolor{title}{fg=brown}
\setbeamercolor{titlelike}{fg=brown}
顏色可以像往常一樣定義
\definecolor{chocolate}{RGB}{33,33,33}
塊樣式也可以定義
\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{background canvas}[vertical shading][bottom=white,top=structure.fg!25]
\setbeamertemplate{sidebar canvas left}[horizontal shading][left=white!40!black,right=black]
您還可以抑制導航符號
\beamertemplatenavigationsymbolsempty
字型
[edit | edit source]您還可以更改特定元素的字型。如果您想將由\{frame}[plain]\titlepage\end{frame}呈現的簡報標題設定為襯線字型而不是預設的無襯線字型,您將使用
\setbeamerfont{title}{family=\rmfamily}
如果您使用的是帶有 Xe(La)TeX 的 OpenType 字型,並且要指定帶有更大尺寸和舊式比例替代數字字形的襯線字型,則可以更進一步
\setbeamerfont{title}{family=\rmfamily\addfontfeatures{Scale=1.18, Numbers={Lining, Proportional}}}
數學字型
[edit | edit source]beamer 的預設設定使用的是與建立簡單數學文章時所期望的不同數學字型集。一個快速解決方法是使用
\usefonttheme[onlymath]{serif}
幀選項
[edit | edit source]幀的選項可以按以下方式傳遞
\begin{frame}[option1,option2,...,option N]{Title of the frame}
% ...
\end{frame}
以下是部分有用選項及其說明。
- plain : 此選項將從幻燈片中刪除所有格式,從而為您提供更多空間來容納大型圖形或大型表格。
- shrink: 如果要在幻燈片上包含大量文字,請使用shrink選項。
- allowframebreaks : 選項將在內容過多而無法在一張幻燈片上顯示時自動建立新的幻燈片。
- fragile: 在使用任何逐字環境(如listings)之前,您應該將選項fragile傳遞給
frame環境,因為逐字環境需要以不同的方式排版。通常,可以使用fragile=singleslide形式(有關詳細資訊,請參見手冊)。請注意,fragile選項不能與\frame命令一起使用,因為它期望遇到一個\end{frame},它應該單獨位於一行。
\begin{frame}[fragile]
\frametitle{Source code}
\begin{lstlisting}[caption=First C example]
int main()
{
printf("Hello World!");
return 0;
}
\end{lstlisting}
\end{frame}
超連結導航
[edit | edit source]可以在 beamer 中使用內部和外部超連結來輔助導航。還可以新增外觀整潔的按鈕。
預設情況下,beamer 類會在右下角新增導航按鈕。要刪除它們,可以在序言中放置
\beamertemplatenavigationsymbolsempty
。
動畫
[edit | edit source]可以使用諸如 \pause、\uncover、\only 和 \itemize<a-b>之類的命令來使圖形和文字出現和消失。這些命令後的文字或圖形將在以下事件之一發生後顯示(在不同的 PDF 檢視器中可能會有所不同):按鍵盤上的空格鍵、回車鍵或分頁鍵,或使用滑鼠向下滾動或單擊下一張幻燈片按鈕。以下是每個命令的簡短說明,有關詳細資訊,請參閱 Beamer 手冊的第 9 章。
\pause 語句可以按以下方式使用,以提供一個斷點。也就是說,命令後的文字將在下一個事件(按鈕點選/按鍵/等)上顯示
\begin{frame}
\frametitle{Some background}
We start our discussion with some concepts.
\pause
The first concept we introduce originates with Erd\H os.
\end{frame}
\uncover 命令顯式指定出現;\only 的工作原理相同,但隱藏時不會保留空間。
\begin{frame}
\frametitle{Some background}
\only<1>{To be replaced.}
\uncover<2-3>{Only visible on slides two and three.}
\uncover<4->{Can be seen afterwards until the end.}
\end{frame}
\item 命令透過使用<a-b>來指定文字的出現和消失,其中a和b是該專案要顯示的事件編號(包含)。例如
\begin{itemize}
\item This one is always shown
\item<1-> The first time (i.e. as soon as the slide loads)
\item<2-> The second time
\item<1-> Also the first time
\only<1-1> {This one is shown at the first time, but it will hide soon (on the next event after the slide loads).}
\end{itemize}
一種更簡單的逐次點選顯示一項的方法是使用\{itemize}[<+->]。
\begin{frame}
\frametitle{`Hidden higher-order concepts?'}
\begin{itemize}[<+->]
\item The truths of arithmetic which are independent of PA in some
sense themselves `{contain} essentially {\color{blue}{hidden higher-order}},
or infinitary, concepts'???
\item `Truths in the language of arithmetic which \ldots
\item That suggests stronger version of Isaacson's thesis.
\end{itemize}
\end{frame}
在所有這些情況下,按分頁鍵、向上滾動或在導航欄中單擊上一張幻燈片按鈕將回溯到序列中。
上述命令將揭開專案,並且它們僅在指定幀號上/之後可見。也可以使用\setbeamercovered{transparent}命令來檢視未覆蓋的專案,這些專案將以較低的透明度顯示。這意味著,如果可見文字為黑色,則未覆蓋的文字將為灰色。可以使用\setbeamercovered{invisible}命令恢復此設定。
格式化文字也有類似的選項。例如,如果您希望文字具有特定樣式,則可以使用\style<3->{Text}命令。例如,可以使用\alert<3->{Some text.},它將在指定幻燈片上以相應的格式顯示指定的文字。同樣,也可以使用
\textbf, \textit, \textsl, \textrm, \textsf, \textcolor, \structure 等命令。
定理、推論和證明環境也是如此。以下是一個示例。
\begin{theorem}<2->[Famous identity]
$ e^i -1 = 0$
\end{theorem}
對於表格,必須在放置新行(即 \\)之前新增\onslide 幻燈片命令。
Test 1 & repeat & 14.5 & 656 \onslide<3-> \\
手冊模式
[edit | edit source]在 beamer 類中,預設模式為presentation,它會製作幻燈片。但是,您可以透過在呼叫類時設定此選項,在稱為handout的不同模式下工作
\documentclass[12pt,handout]{beamer}
此模式對於一次只檢視一張幻燈片及其所有內容非常有用,使任何\itemize[<+->] 環境都一次可見(例如,可列印版本)。但是,這在使用only 命令時會出現問題,因為它的目的是一次只顯示某些文字或圖形,而不是全部顯示。
如果要解決此問題,可以新增一個語句來精確指定在處理手冊模式下的only 命令時的行為。假設您有一個這樣的程式碼
\only<1>{\includegraphics{pic1}}
\only<2>{\includegraphics{pic2}}
這些圖片完全不同,您希望它們都在手冊中,但它們不能在同一張幻燈片上,因為它們太大。解決方法是新增手冊語句以獲得以下內容
\only<1| handout:1>{\includegraphics{pic1}}
\only<2| handout:2>{\includegraphics{pic2}}
這將確保手冊為每張圖片製作一張幻燈片。
現在想象一下,你仍然擁有兩張圖片,只有陳述,但第二張顯示第一張圖片加上一些其他圖表,你不需要第一張圖片出現在講義中。因此,你可以透過以下方式精確地指定講義模式不包含一些僅有的命令:
\only<1| handout:0>{\includegraphics{pic1}}
\only<2>{\includegraphics{pic2.eps}}
該命令還可以用來隱藏框架,例如:
\begin{frame}<handout:0>
或者,如果你編寫了一個你不再需要的框架,但可能以後會需要它,你可以編寫:
\begin{frame}<0| handout:0>
這將在兩種模式下隱藏你的幻燈片。
關於講義模式的最後一個說明是關於筆記的。實際上,一個框架的完整語法是:
\begin{frame}
...
\end{frame}
\note{...}
\note{...}
...
你可以在“note”欄位中寫入你關於框架的筆記(如果需要,可以寫很多)。利用這一點,你可以新增一個選項:
\setbeameroption{show only notes}
或者
\setbeameroption{show notes}
第一個選項在你做演講時很有用,因為它只顯示你需要的筆記,而第二個選項可以提供給那些聽過你演講的人或者那些錯過了演講的人,讓他們既可以檢視幻燈片,也可以瞭解你所說的話。
列環境將幻燈片(垂直)劃分為幾列。例如:
\begin{frame}
\frametitle{Example of columns 1}
\begin{columns}[c] % the "c" option specifies center vertical alignment
\column{.45\textwidth} % column designated by a command
Contents of the first column
\column{.45\textwidth}
Contents split \newline into two lines
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Example of columns 2}
\begin{columns}[T] % contents are top vertically aligned
\begin{column}{5cm} % each column can also be its own environment
Contents of first column \newline split into two lines
\end{column}
\begin{column}{5cm} % alternative top-align that's better for graphics
\includegraphics[height=3cm]{graphic}
\end{column}
\end{columns}
\end{frame}
將文字包含在“block”環境中會建立一個獨特的,帶標題的文字塊(可以使用空白標題)。這可以讓你輕鬆地直觀區分幻燈片的各個部分。有三種基本型別的塊。它們的格式取決於所使用的主題。
\begin{frame}
\begin{block}{This is a Block}
This is important information
\end{block}
\begin{alertblock}{This is an Alert block}
This is an important alert
\end{alertblock}
\begin{exampleblock}{This is an Example block}
This is an example
\end{exampleblock}
\end{frame}
你可以指定PDF的預設選項。[2]
\hypersetup{pdfstartview={Fit}} % fits the presentation to the window when first displayed
可以使用這段程式碼為幻燈片編號:
\insertframenumber/\inserttotalframenumber
但是,這對於一些簡報作者來說會帶來兩個問題:標題幻燈片被編號為第一個,並且附錄或所謂的“備份” (又名附錄,備用) 幻燈片被包含在總計中,儘管它們不打算在被問到“硬”問題之前公開。[3] 這時,有兩個功能可以解決這個問題:
- 能夠將某些框架排除在編號之外。例如,這可以用於標題幻燈片,以避免對其進行計數。
\begin{frame}[noframenumbering]
content...
\end{frame}
- 這些東西可以解決計算備份框架的問題。
\documentclass[12pt,handout]{beamer}
\usetheme{CambridgeUS}
\setbeamertemplate{page number in head/foot}[appendixframenumber]
\begin{document}
\begin{frame}
content
\end{frame}
\appendix
\begin{frame}
content...
\end{frame}
\end{document}
powerdot 包是 beamer 的替代方案。它可以在 CTAN 中獲得。文件詳細解釋了其功能。
powerdot 包透過呼叫 powerdot 類載入。
\documentclass{powerdot}
然後可以指定通常的標題資訊。
在通常的 document 環境中,多個 slide 環境指定要放在每個幻燈片上的內容。
\begin{document}
\begin{slide}{This is the first slide}
%Content goes here
\end{slide}
\begin{slide}{This is the second slide}
%More content goes here
\end{slide}
% etc
\end{document}
beamer 類非常強大,並提供了許多功能。對於非常簡單的簡報,可以使用基於 article 的類。
\documentclass[paper=160mm:90mm,fontsize=10pt,DIV=16]{scrartcl}
\usepackage{lmodern}
\pagestyle{empty}
\renewcommand{\familydefault}{\sfdefault}
\newenvironment{slide}[1]{\clearpage
{\LARGE\bfseries#1\par}\vspace{\baselineskip}
}{}
\usepackage{enumitem}
\setlist{noitemsep}
\title{XeTaL}
\author{Carl Capybara}
\begin{document}
\maketitle
\begin{slide}{slide title}
This is just some text
\begin{itemize}
\item Wombat
\item Capybara
\item Mara
\end{itemize}
\end{slide}
\begin{slide}{Wombat title}
This is just some different text
\end{slide}
\end{document}
以下是一些簡報的精彩示例:
- ↑ Andrew Mertz 和 William Slough, Beamer by Example
- ↑ hyperref 手冊中定義了其他可能的取值
- ↑ Beamer 中的附錄幻燈片:控制框架編號
- 維基百科:Beamer (LaTeX)
- Beamer 使用者指南 (pdf) 來自 CTAN
- The powerdot 類 (pdf) 來自 CTAN
- 使用 beamer 建立簡報的教程



