Try   HackMD

LaTeX 教學系列:用 Beamer 製作簡報

tags: LaTeX

為何使用

LATEX 進行簡報製作呢,使用
LATEX
製作簡報,個人認為大致有以下優點,首先是學術性強大,包含版面、顯示方式等,都能夠讓讀者或閱聽人看到沈穩的簡報內容與外觀,從而能夠專注聽講。另一個優點則是輸出的內容可以跨平台使用,因其產生的檔案類型為.pdf檔,故能夠避免使用.pptx時字體在其他電腦未安裝而無法顯示的窘境。不過缺點大概就是 coding 很麻煩!使用
LATEX
做出來的簡報我們稱為 beamer(以下我們也這樣稱呼),可以先來看一個簡單的例子:

\documentclass{beamer}
\title{Sample title}
\author{Anonymous}
\institute{Overleaf}
\date{2021}
\begin{document}
\frame{\titlepage}
\begin {frame}
\frametitle{Sample frame title}
This is some text in the first frame.
\end {frame}
\end{document}

可以看到我們是以frame這個環境產生簡報的一個頁面。接著我們就針對 beamer 的細節進行更細緻的討論。

幀(frame)

如同上面提到的,frame環境是產生 beamer 頁面的關鍵。frame環境的設定如下:

\begin{frame}[頁面設定]
\frametitle{頁面標題}
\framesubtitle{頁面副標題}
頁面內容
\end{frame}

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

加入頁面標題時必須使用\frametitle{},而[頁面設定]的部分則留到後面幾個小節再討論。

標題頁

如果想要顯示標題頁,可以在前言區先加入標題資訊

\title[About Beamer] %optional
{About the Beamer class in presentation making}

\subtitle{A short story}

\author[Anthony, Ben] % (optional)
{Anthony\inst{1} \and Ben\inst{2}}

\institute[NTU] % (optional)
{
  \inst{1}%
  Department of Political Science\\
  National Taiwan University
  \and
  \inst{2}%
  Department of Economics\\
  National Taiwan University
}

\date[2021] % (optional)
{Very Large Conference, April 2021}

接著在frame環境內加上\titlepage

\begin{frame}
\titlepage
\end{frame}

結果就會是:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

或是可以使用\frame{\titlepage},更加簡潔有力。如果想要在標題頁加上 logo,則使用\logo{\includegraphics{logo 檔案}}

目錄頁

通常來說,在一份演講簡報中都會含有目錄頁,目的是為了讓觀眾能夠先快速地掌握本次演講的重點,從而能夠在之後的演講中抓到其想要了解的重要資訊。加入目錄頁的方式跟標題頁十分相似,只要改為\tableofcontents即可。

\titlepage

\begin{frame}
\tableofcontents
\end{frame}

當然,如果你直接將上面的程式碼放到你的.tex檔案裡面是不會跑出東西的,我們在使用目錄頁的時候必須確認已經加入\section\subsection等資訊。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

簡報內容的細節

在了解完如何產生一個又一個的簡報頁面後,接下來我們要針對簡報內部的內容進行討論。

列點與條列

假設演講者想要將其所欲說明的資訊以列點的方式呈現,我們有以下兩種工具。首先是無序的列點,其結果只會是一個個的幾何圖案,我們使用itemize環境來達到此目的:

\begin{itemize}
\item The first item
\item The second item
\item The third item
\item The fourth item
\end{itemize}

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

如果想要改為原點,則在\item後面加上[$\bullet$],就會變成以下的形式:

\begin{itemize}
\item[$\bullet$] Circle
\item Triangle
\end{itemize}

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

另一個方法則是有序列點,方法為使用enumerate環境,即

\begin{enumerate}
\item The first item
\item The second item
\item The third item
\item The fourth item
\end{enumerate}

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

分欄

作為簡報者,當然會想要簡報越能簡短的報告出越詳細的內容越好,因此常會在圖片、文字旁邊加上註解、說明文字,又或是進行比較。此時就需要使用columns環境:

\begin{columns}
\begin{column}{寬度(小數點)\textwidth}
文字/圖片
\end{colimn}
\begin{column}{寬度(小數點)\textwidth}
文字/圖片
\end{colimn}
\end{columns}

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

區塊

區塊可以將一般文字與想要強調的文字、公式等區分開,這個目的具有強調、警示的作用,能夠讓觀眾看到此張投影片的重點。例如我們想要將正弦半角公式放到投影片中,可以這麼做:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

beamer 也有提供底下的幾個環境:

  • block 普通環境
  • theorem 定理環境
  • lemma 引理環境
  • proof 證明環境
  • corollary 推論環境
  • example 示例環境
  • alertblock 警示環境

beamer 顏色與主題

為了讓簡報看起來不單調,可以使用 beamer 中的主題功能,為簡報頁面增添色彩,我們使用\usetheme{主題}改變 beamer 的主題,並以\usecolortheme{顏色主題}改變 beamer 整體的顏色配置。關於更多的顏色配置與主題,可以參考 Another Beamer Theme

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Overlay 的控制

.pptx中,我們可以透過加上動畫來將演講中的某些內容以動態的方式呈現。在 beamer 中我們雖然沒有精緻的動畫可呈現,但我們可以透過類似讓內容一個一個跑出來的概念達到這個目的。

pause 的用法

最基本的 overlay 就是用\pause來做暫停,使用方法如下:

\begin{frame}
內容 1
\pause
內容 2
\pause
內容 3
\end{frame}

輸出成.pdf檔後就會產生三張投影片。同樣的,在列點的環境中我們也能使用這樣的功能:

\begin{frame}
    \begin{enumerate}
        \item Content 1
        \pause
        \item Content 2
        \pause
        \item Content 3
    \end{enumerate}
\end{frame}

區塊功能也可以使用,這部分就留給讀者自己去嘗試。

顯示程式碼

許多資工系或是會遇到需要報告程式碼的使用者,在一般的 PowerPoint 輸入程式碼後,程式碼的字體、排版不會太美觀,而 beamer 便提供了此功能(一般文件也可以使用)。在 beamer 要引用程式碼請使用verbatimlistings套件。不過, 在使用可以顯示的投影片前,必需使用fragile的設定:

\begin{frame}[fragile]

\end{frame}

接著我們就可以在投影片中加入程式碼:

\begin{frame}[fragile]
\begin{lstlisting}
# 程式碼
\end{lstlisting}
\end{frame}

如果想要在文中顯示程式碼,可以使用\path{指令}或是\verb|指令|

按鈕與指定頁面

若要如 PowerPoint 一般,能夠跳到指定頁面,首先要將某頁投影片貼上標籤,即:

\begin{frame}[label=here]

\end{frame}

接著就可以製作按鈕:

\hyperlink{here}{\beamerbutton{按鈕文字}}