
注:请翻到文章末尾下载生成本文slides的源代码。
目录
为什么用beamer?
什么是beamer?
如何用beamer做幻灯片?
有哪些值得注意的小技巧?
为什么用beamer?
前段时间在赶一个paper的同时,在准备一个会议的presentation。在准备PPT的时候,刚开始还很愉快,封面,目录,introduction,到了related work就开始崩溃了,因为公式!!!那么忙,为什么要手动再输入一遍那些公式?完全是无意义的重复劳动。于是上网搜了下ppt能不能识别latex公式,结果找到了beamer!感动哭!这不就是我一直想要的?!!
对于学术会议、学术演讲的presenter而言,默认是已经有了latex版本的论文。用beamer做PPT简直太省事了!
什么是beamer?
beamer是一个强大而灵活的latex文档类,用于创建外观很棒的演示文稿,具有海量的模板可以用。
简单的说,用latex排版论文的几乎所有优点它都有,公式排版与编号、图文排版编号、参考文献版本编号都一样,直接从论文中复制过来就可以用!!!
只不过beamer做出来的是幻灯片效果!
如何用beamer做幻灯片?
这一节介绍最简单基本的功能:创建标题页面、添加徽标、制作目录、添加动画效果、公式页面、图表页面、添加参考文献。下一节介绍更多特征。
标题页面
效果
包含标题,副标题,作者,作者所属单位,会议名词,时间,自定义logo(此处用的大师姐头像),页脚(包含作者及单位缩写,标题缩写,会议名词缩写,页码)。

1.首先在 begin{document}之前的前导码(preamble)部分插入下面这一段标题页内容
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
title[About Beamer] %optional
{About the Beamer class in presentation making}
subtitle{A short story}
author[Arthur, Doe] % (optional, for multiple authors)
{A.~B.~Arthurinst{1} and J.~Doeinst{2}}
institute[VFU] % (optional)
{
inst{1}%
Faculty of Physics
Very Famous University
and
inst{2}%
Faculty of Chemistry
Very Famous University
}
date[VLC 2020] % (optional)
{Very Large Conference, April 2013}
logo{includegraphics[height=1cm]{logo.png}}
2.然后在begin{document} 后,插入标题页面。在beamer中任何一页都是放在begin{frame}和end{frame}之间的环境中的。
% insert title page---------------------------
begin{frame}
titlepage % Print the title page as the first slide
end{frame}
目录页面
效果

1.首先根据内容将整个slides分节
section{Introduction}
%followed by pages of this section
section{Related work}
%followed by pages of this section
section{Proposed method}
%followed by pages of this section
section{Experiments}
%followed by pages of this section
section{Conclusion}
%followed by pages of this section
2.然后在标题页后面插入目录页。
%insert contents------------------------------
begin{frame}
frametitle{Table of Contents}
tableofcontents
end{frame}
3.设置在每一个小节之前插入强调该小节的标题页
效果

实现:在 begin{document}之前的前导码(preamble)部分插入下面这一段设置即可:
%----------------------------------------------------------------------------------------
% Highlight the title of the current section
%----------------------------------------------------------------------------------------
AtBeginSection[]
{
begin{frame}
frametitle{Table of Contents}
tableofcontents[currentsection]
end{frame}
}
正文页面无动画版
效果

实现:
% insert a sample frame without animation--------------------------------
begin{frame}
frametitle{Sample frame title without animation}
This is a text in second frame. For the sake of showing an example.
begin{itemize}
item Text visible on slide 1
item Text visible on slide 2
item Text visible on slide 3 % pay attention to this line, you can omit the content by omit the '-'
item Text visible on slide 4
end{itemize}
end{frame}
正文页面有动画版1
效果

实现:
% insert a sample frame with animation -------------------------------------
begin{frame}
frametitle{Sample frame title with animation}
This is a text in second frame. For the sake of showing an example.
begin{itemize}
item<1-> Text visible on slide 1
item<2-> Text visible on slide 2
item<3> Text visible on slide 3 % pay attention to this line, you can omit the content by omit the '-'
item<4-> Text visible on slide 4
end{itemize}
end{frame}
注意:1.beamer编译之后生成的是pdf文档,它实现动画是通过将一个frame的内容生成多个页面通过翻页实现的视觉效果。也就是说上面一个frame环境会生成如动图所示的4个页面。因此,在beamer中frame和页面之间并非严格一一对应的。
2.比较动画版和非动画可以发现,区别在于在 item后是否有‘<1->’这样的用于分页的标志。 注意item<3> 数字3后面没有短横线,这表示在下一页中不显示这一个条目。
可以通过运行文章末尾的源代码来更好的理解这两个注意事项。
正文页面有动画版2
上面的例子中是在begin{itemize} end{itemize}
的列表中实现的动画,事实上,任何文本或者段落都可以通过 pause来实现动画。效果如下:

实现:
% insert a sample frame with animation 2 -----------------------------------
begin{frame}
In this slide pause
the text will be partially visible pause
And finally everything will be there
end{frame}
注:虽然这里讲了两种动画的实现方式。但是对于学术演讲而言,除非十分必要,不要整这么多动画,讲的时候容易分心播放动画,也感觉不够严肃。
正文页如何强调、高亮重要内容?
下图提供了4种高亮效果,文字标红,以及三种不同颜色的强调框。

实现:注意,beamer定义了alert{}命令来高亮文本。另外分别定义了3种不同的环境block, alertblock, examples来定义不同颜色的强调框。颜色、主题设置将在下一小节讲解。
% insert a sample frame with highlighe -----------------------------------
begin{frame}
frametitle{Sample frame title}
In this slide, some important text will be
alert{highlighted} because it's important.
Please, don't abuse it.
begin{block}{Remark}
Sample text
end{block}
begin{alertblock}{Important theorem}
Sample text in red box
end{alertblock}
begin{examples}
Sample text in green box. The title of the block is ``Examples".
end{examples}
end{frame}
带公式页面
效果

实现:与latex写论文一模一样,包括自动编号,包括标签设置和引用,直接复制过来即可。
% insert a sample frame with formula -----------------------------------
begin{frame}
frametitle{Sample frame with formula}
In this slide, we insert an equation (ref{E1}), which is the definition of $y$.
begin{equation}
label{E1}
y=
begin{cases}
frac{1}{f(x)}, f(x) neq 0
f(x), f(x)=0
end{cases}
end{equation}
end{frame}
带图片页面
效果

实现:与latex写论文一模一样,包括自动编号,包括标签设置和引用,包括设置标题,直接复制过来即可。
% insert a sample frame with a figure -----------------------------------
begin{frame}
frametitle{Dataset}
The dataset information is shown in Fig. ref{dataset}.
begin{figure}[ht]
centering
includegraphics[width=0.8textwidth]{dataset.png}
caption{A picture downloaded from the Internet.png}
label{dataset}
end{figure}
end{frame}
该页图片来源于网络[1]。
带表格页面
效果

实现:与latex写论文一模一样,包括自动编号,包括标签设置和引用,包括设置标题,直接复制过来即可。
% insert a sample frame with a table -----------------------------------
begin{frame}
frametitle{A sample frame with a table}
begin{table}[ht]
caption{A sample table}
label{T1}
centering
begin{tabular}{p{1.5cm}|p{1.5cm}|p{1.5cm}}
hline
Metrics & M1 & M2
hline
Accuracy & 87% & 88%
Precision & 91% & 90%
Recall & 75% & 77%
hline
end{tabular}
end{table}
end{frame}
带参考文献页面
效果

实现:与latex写论文一模一样,包括自动编号,包括引用,直接复制过来即可。本例是放在一个ltemize列表环境里的,也可以直接放在frame环境里。
% insert a sample frame with citation --------------------------------
begin{frame}
frametitle{Literature review}
begin{itemize}
item You can cite a paper like this cite{team2015common,eiram2013cvssv2}.
end{itemize}
end{frame}
参考文献页面
效果

实现:注意,beamber不支持bibtex编译,所以,不支持.bib格式的参考文献。只能用下面这种bbl格式。如果你的参考文献是放在.bib文件里面的,也没关系。你的latex论文编译生成参考文献之后会生成一个.bbl的文件,在这个文件里,你可以复制出你需要的参考文献条目放入slides里面。
% insert a reference frame before the 'thank you' frame ----------------------
begin{frame}
frametitle{References}
begin{thebibliography}{99} % Beamer does not support BibTeX so references must be inserted manually as below
bibitem{team2015common}
Team, C.: Common vulnerability scoring system v3. 0: Specification document.
First. org (2015)
bibitem{eiram2013cvssv2}
Eiram, C., Martin, B.: The cvssv2 shortcomings, faults, and failures
formulation. In: Technical report, Forum of Incident Response and Security
Teams (FIRST) (2013)
end{thebibliography}
end{frame}
注意,beamber不支持bibtex编译,所以,不支持.bib格式的参考文献。只能用下面这种bbl格式。如果你的参考文献是放在.bib文件里面的,也没关系。你的latex论文编译生成参考文献之后会生成一个.bbl的文件,在这个文件里,你可以复制出你需要的参考文献条目放入slides里面。

致谢页面
效果

实现
% Insert a thank your frame ------------------------------------------------
begin{frame}
Huge{centerline{Thank you!}}
end{frame}
至此,已经可以根据一个文字的latex源代码,快速做出一个标(dai)准(ban)的学术演讲slides。下一小节讲解一些调节颜色、字体、主题等个性化小技巧。
有哪些值得注意的小技巧?
1.设置主题和颜色主题
本文所用主题为Madrid,颜色主题为default。设置为:
documentclass{beamer}
usetheme{Madrid}
改变颜色主题的效果为:

实现:
documentclass{beamer}
usetheme{Madrid}
usecolortheme{beaver}
beamer提供多种主题theme和颜色主题colortheme供选择。如下图是主题和颜色主题搭配的效果,行为主题,列为颜色主题:

2.字体和文字大小设置
文字大小可在documentclass[17pt]{beamer}通过参数设置。可用的大小有8pt, 9pt, 10pt, 11pt, 12pt, 14pt, 17pt, 20pt,默认为 11pt (对应全屏模式下的22pt)。
documentclass[17pt]{beamer}
字体可通过fonttheme设置,可用的字体有:structurebold, structurebolditalic, structuresmallcapsserif, structureitalicsserif, serif 以及 default。例如:
documentclass{beamer}
usefonttheme{structuresmallcapsserif}
usetheme{Madrid}
此外,字体还可以通过引入相应的包来设置,常用的包有:mathptmx, helvet, avat, bookman, chancery, charter, culer, mathtime, mathptm, newcent, palatino, pifont and utopia.
documentclass{beamer}
usepackage{bookman}
usetheme{Madrid}
下图就是bookman字体效果:

3.页面分栏设置
效果

实现
% insert a sample frame with two columns --------------------------------
column{0.5textwidth}
This is a text in first column.
$$E=mc^2$$
begin{itemize}
item First item
item Second item
end{itemize}
column{0.5textwidth}
This text will be in the second column
and on a second tought this is a nice looking
layout in some cases.
end{columns}
end{frame}
其他
更多主题、颜色主题、字体主题的呈现效果可以在这个网页查看:
https://deic-web.uab.cat/~iblanes/beamer_gallery/index.html

本文主要参考网页为:Overleaf, Online LaTeX Editor
与beamer类似的用于做slides的还有powerdot,具体参考:Overleaf, Online LaTeX Editor
用latex做poster,请参考这个网页:https://www.overleaf.com/learn/latex/Posters
全文源代码合集
全文源代码合集,请复制粘贴到txt文档,然后重命名为.tex 为了防止报错,已经把涉及图片的地方注释掉了。自己用的时候取消注释,换成自己的图片即可。
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Beamer Presentation
% LaTeX Template
% Version 1.0 (10/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% PACKAGES AND THEMES
%----------------------------------------------------------------------------------------
documentclass{beamer}
setbeamertemplate{caption}[numbered]
setbeamertemplate{bibliography item}[text]
mode<presentation> {
% The Beamer class comes with a number of default slide themes which change the colors and layouts of slides. Below this is a list of all the themes, uncomment each in turn to see what they look like.
%
%usetheme{default}
%usetheme{AnnArbor}
%usetheme{Antibes}
%usetheme{Bergen}
%usetheme{Berkeley}
%usetheme{Berlin}
%usetheme{Boadilla}
%usetheme{CambridgeUS}
%usetheme{Copenhagen}
%usetheme{Darmstadt}
%usetheme{Dresden}
%usetheme{Frankfurt}
%usetheme{Goettingen}
%usetheme{Hannover}
%usetheme{Ilmenau}
%usetheme{JuanLesPins}
%usetheme{Luebeck}
usetheme{Madrid}
%usetheme{Malmoe}
%usetheme{Marburg}
%usetheme{Montpellier}
%usetheme{PaloAlto}
%usetheme{Pittsburgh}
%usetheme{Rochester}
%usetheme{Singapore}
%usetheme{Szeged}
%usetheme{Warsaw}
% As well as themes, the Beamer class has a number of color themes
% for any slide theme. Uncomment each of these in turn to see how it
% changes the colors of your current slide theme.
%usecolortheme{albatross}
%usecolortheme{beaver}
%usecolortheme{beetle}
%usecolortheme{crane}
%usecolortheme{dolphin}
%usecolortheme{dove}
%usecolortheme{fly}
%usecolortheme{lily}
%usecolortheme{orchid}
%usecolortheme{rose}
%usecolortheme{seagull}
%usecolortheme{seahorse}
%usecolortheme{whale}
%usecolortheme{wolverine}
%setbeamertemplate{footline} % To remove the footer line in all slides uncomment this line
%setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line
%setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line
}
%usepackage{bookman} % the used font
usepackage{graphicx} % Allows including images
usepackage{booktabs} % Allows the use of toprule, midrule and bottomrule in tables
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
title[About Beamer] %optional
{About the Beamer class in presentation making}
subtitle{A short story}
author[Arthur, Doe] % (optional, for multiple authors)
{A.~B.~Arthurinst{1} and J.~Doeinst{2}}
institute[VFU] % (optional)
{
inst{1}%
Faculty of Physics
Very Famous University
and
inst{2}%
Faculty of Chemistry
Very Famous University
}
date[VLC 2020] % (optional)
{Very Large Conference, April 2013}
%logo{includegraphics[height=0.5cm]{logo.png}}
%----------------------------------------------------------------------------------------
% Highlight the title of the current section
%----------------------------------------------------------------------------------------
AtBeginSection[]
{
begin{frame}
frametitle{Table of Contents}
tableofcontents[currentsection]
end{frame}
}
%----------------------------------------------------------------------------------------
% All pages in the slides
%----------------------------------------------------------------------------------------
begin{document}
% insert title page---------------------------
frame{titlepage}
%insert contents------------------------------
begin{frame}
frametitle{Table of Contents}
tableofcontents
end{frame}
section{Introduction}
% insert a sample frame without animation--------------------------------
begin{frame}
frametitle{Sample frame title without animation}
This is a text in second frame. For the sake of showing an example.
begin{itemize}
item Text visible on slide 1
item Text visible on slide 2
item Text visible on slide 3 % pay attention to this line, you can omit the content by omit the '-'
item Text visible on slide 4
end{itemize}
end{frame}
% insert a sample frame with animation 1 ----------------------------------
begin{frame}
frametitle{Sample frame title with animation}
This is a text in second frame. For the sake of showing an example.
begin{itemize}
item<1-> Text visible on slide 1
item<2-> Text visible on slide 2
item<3> Text visible on slide 3 % pay attention to this line, you can omit the content by omit the '-'
item<4-> Text visible on slide 4
end{itemize}
end{frame}
% insert a sample frame with animation 2 -----------------------------------
begin{frame}
In this slide pause
the text will be partially visible pause
And finally everything will be there
end{frame}
section{Related work}
% insert a sample frame with highlighe -----------------------------------
begin{frame}
frametitle{Sample frame title}
In this slide, some important text will be
alert{highlighted} because it's important.
Please, don't abuse it.
begin{block}{Remark}
Sample text
end{block}
begin{alertblock}{Important theorem}
Sample text in red box
end{alertblock}
begin{examples}
Sample text in green box. The title of the block is ``Examples".
end{examples}
end{frame}
section{Proposed method}
% insert a sample frame with formula -----------------------------------
begin{frame}
frametitle{Sample frame with formula}
In this slide, we insert an equation (ref{E1}), which is the definition of $y$.
begin{equation}
label{E1}
y=
begin{cases}
frac{1}{f(x)}, f(x) neq 0
f(x), f(x)=0
end{cases}
end{equation}
end{frame}
section{Experiments}
% insert a sample frame with a figure -----------------------------------
begin{frame}
frametitle{Dataset}
The dataset information is shown in Fig. ref{dataset}.
%
%begin{figure}[ht]
%centering
%includegraphics[width=0.8textwidth]{dataset.png}
%caption{A picture downloaded from the Internet.png}
%label{dataset}
%end{figure}
end{frame}
% insert a sample frame with a table -----------------------------------
begin{frame}
frametitle{A sample frame with a table}
begin{table}[ht]
caption{A sample table}
label{T1}
centering
begin{tabular}{p{1.5cm}|p{1.5cm}|p{1.5cm}}
hline
Metrics & M1 & M2
hline
Accuracy & 87% & 88%
Precision & 91% & 90%
Recall & 75% & 77%
hline
end{tabular}
end{table}
end{frame}
section{Conclusion}
begin{frame}
frametitle{Two-column slide}
begin{columns}
% insert a sample frame with two columns --------------------------------
column{0.5textwidth}
This is a text in first column.
$$E=mc^2$$
begin{itemize}
item First item
item Second item
end{itemize}
column{0.5textwidth}
This text will be in the second column
and on a second tought this is a nice looking
layout in some cases.
end{columns}
end{frame}
% insert a sample frame with citation --------------------------------
begin{frame}
frametitle{Literature review}
begin{itemize}
item You can cite a paper like this cite{team2015common,eiram2013cvssv2}.
end{itemize}
end{frame}
% insert a reference frame before the 'thank you' frame ----------------------
begin{frame}
frametitle{References}
begin{thebibliography}{99} % Beamer does not support BibTeX so references must be inserted manually as below
bibitem{team2015common}
Team, C.: Common vulnerability scoring system v3. 0: Specification document.
First. org (2015)
bibitem{eiram2013cvssv2}
Eiram, C., Martin, B.: The cvssv2 shortcomings, faults, and failures
formulation. In: Technical report, Forum of Incident Response and Security
Teams (FIRST) (2013)
end{thebibliography}
end{frame}
% Insert a thank your frame ------------------------------------------------
begin{frame}
Huge{centerline{Thank you!}}
end{frame}
end{document}
参考
- ^https://www.researchgate.net/figure/Average-number-of-clusters-in-datasets-of-varying-size-bar-graph-and-frequency-of_fig2_264390026