该文档总体由beamer-latex的教程而来,由耳东小白以自身学习路径整理。因其中要点基本按照教程的顺序和结构整理,故而不能称之为完全原创,但也不是翻译,更不是抄袭,是个人自学笔记和批注,其中添加了小白个人的理解和整合,较之原英文教程多出些适用中文编辑的内容。CSDN只有原创和翻译的投稿选项,这里不是翻译,因此投稿投了原创。如果读者对此特别介意,请省流绕行,自行查看英文原版教程,特此说明。
1 中文环境、标题页和最小ppt
首先我们需要指定编译器为xeLaTeX,这是通过头部的注释来完成的。
% !TEX program = xelatex
然后导入beamer类,即为
\documentclass[aspectratio=169]{beamer}
注意中间参数设置aspectratio为169,表示页面比例是16比9。
设置页面主题和颜色主题:
\usetheme{AnnArbor}
\usecolortheme{crane}
接下来需要设置中文环境,否则输入中文时可能会导致编译不通过。
\usepackage{fontspec}
\usepackage{xeCJK}
\setmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setCJKmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setsansfont{Arial}
\setmonofont{Consolas}
\usepackage{fontspec}引入的宏包为字体控制,\usepackage{xeCJK}引入的xeCJK宏包支持中文输入。
下面是一些第三方字体设置:
\setmainfont设置的是主字体,注意,在C:\Windows\Fonts\下可以查到可用的第三方字体。例如本小白就在这里设置了AlibabaPuHuiTi-3-55-Regular.ttf即为阿里巴巴普惠体的常规粗度。(关于第三方字体的设置,请参看小白的另一篇博客)
下面设置标题、作者和时间
\title{耳东小白的beamer学习测试}
\author{耳东小白}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
This is your first presentation!
\end{frame}
\end{document}
其中,\title设置标题,\author设置作者,\date设置当前日期,注意\date不要拼写成\data。
总体,上述成为一个支持中文的最小ppt结构,我们把整体文件整理一下:
% !TEX program = xelatex
\documentclass[aspectratio=169]{beamer}
\usetheme{AnnArbor}
\usecolortheme{crane}
\usepackage{fontspec}
\usepackage{xeCJK}
\setmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setCJKmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setsansfont{Arial}
\setmonofont{Consolas}
\title{耳东小白的beamer学习测试}
\author{耳东小白}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
This is your first presentation!
\end{frame}
\end{document}
效果图如下所示:

2 副标题、多作者、机构名
$$刚刚这个基础版的ppt肯定看上去还很简陋,那么我们来丰富一下它。首先来看一下副标题。
\title{耳东小白的beamer学习测试}
\subtitle{哆哆嗦嗦的历险之旅}
\author{耳东小白}
\date{\today}
即在主标题下,添加\subtitle{}来填写副标题。
假如有多个作者怎么办呢?
\title{耳东小白的beamer学习测试}
\subtitle{哆哆嗦嗦的历险之旅}
\author{耳东小白 \and 耳东大白}
\date{\today}
那就在\author中用\and来区分不同的作者。
如何插入作者的单位名称呢?
\title{耳东小白的beamer学习测试}
\subtitle{哆哆嗦嗦的历险之旅}
\author{耳东小白\inst{1} \and 耳东大白\inst{2}}
\institute{\inst{1} 耳东小白工作室 \and \inst{2} 耳东大白工作室}
\date{\today}
使用\institute来编辑作者的机构名称,如果有多个单位,则使用\inst{#}来指定,在\author中相应的人名后同样以\inst{#}来指定对应的单位名称。
以上这段修改的效果如下:

3 底部脚注设置
注意到页面底部分左、中、右三个部分。这些脚注可以进行设置。
\title[中间脚注]{耳东小白的beamer学习测试}
\subtitle{哆哆嗦嗦的历险之旅}
\author[左侧脚注]{耳东小白\inst{1} \and 耳东大白\inst{2}}
\institute[]{\inst{1} 耳东小白工作室 \and \inst{2} 耳东大白工作室}
\date[右侧脚注]{\today}
\title[]{}中间框中可以填写出底部中央的脚注,\author[]{}中间框内可以填写出底部左侧的脚注,date[]{}中间框内可以填写出底部右侧的脚注。
注意到\institute[]{}中间框留空,否则左侧底框还是会把机构名填进去。
同理,如果希望对应位置的脚注为空,只需要在\title、\author、\date对应的中框留空即可。
上述代码的效果如下图所示:

4 Logo添加到所有页面
这里的Logo有点像是powerpoint中的母版了,可以做到“一次插入,页页见效”。
\logo{
\includegraphics[width=1cm]{./pics/logo.png}
}
注意插入这段代码的位置,是在\date命令之后。宽度设置为1cm,大括号中引用的是logo图像的地址。
插入的位置都在页面的右下角。

5 Logo只添加到封面页
那么如何只添加logo到封面页?只需要把上面的\logo命令替换成\titlegraphic即可:
\titlegraphic{
\includegraphics[width=2cm]{./pics/logo.png}
}
这样只有封面页有添加logo图像,且logo会出现在封面正中。

6 封面插入多个logo
还是刚刚的\titlegraphic命令,利用\hspace命令对多个\includegraphics进行等距离排列(以页面底部正中为中心向两边排列)。
\titlegraphic{
\includegraphics[width=2cm]{./pics/logo.png}
\hspace{2cm}
\includegraphics[width=2cm]{./pics/logo.png}
\hspace{2cm}
\includegraphics[width=2cm]{./pics/logo.png}
}
这样的结果就会变成:

7 指定位置放置logo
如何在页面中指定的位置放置logo图像呢?这个地方要用到一个图像绘制库tikz。
% !TEX program = xelatex
\documentclass[aspectratio=169]{beamer}
\usetheme{AnnArbor}
\usecolortheme{crane}
\usepackage{fontspec}
\usepackage{xeCJK}
\usepackage{tikz}
\setmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setCJKmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setsansfont{Arial}
\setmonofont{Consolas}
\title[中间脚注]{耳东小白的beamer学习测试}
\subtitle{哆哆嗦嗦的历险之旅}
\author[左侧脚注]{耳东小白\inst{1} \and 耳东大白\inst{2}}
\institute[]{\inst{1} 耳东小白工作室 \and \inst{2} 耳东大白工作室}
\date[右侧脚注]{\today}
\titlegraphic{
\begin{tikzpicture}[overlay, remember picture]
\node[left=0.2cm] at (current page.15){
\includegraphics[width = 1cm]{./pics/Logo.png}};
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
This is your first presentation!
\end{frame}
\end{document}

这里需要加载tikz宏包即\usepackage{tikz}。
然后在页面上指定一个位置即:
\node[left=0.2cm] at (current page.15)
根据tikz库的使用方法,该\node的位置如下图指定:

即基准点为页面的中心点,将水平方向轴以基准点为中心,逆时针旋转15度所得到的位置,再向左偏移0.2cm作为所插入logo图像的起始位置。
关于tikz库的使用,小白发现这是一个比beamer更大的坑,所以这里不作展开。
8 插入目录/要点页
下面我们来看看如何插入目录页。
这个地方要使用到的命令是\tableofcontents。
与office一样,首先你得设置“大纲”,才能有自动生成的目录页。
\section{现存方法}
\subsection{方法1}
\subsection{方法2}
\subsection{方法3}
\section{对比研究}
\section*{参考文献}
小白设置的大纲如上所示。
注意,我们可以使用\section或\subsection来写一级标题和二级标题。
当你希望它不在目录中显示时,则使用\section*或\subsection*命令,也即在命令后加一个星号。
然后,需要插入一个目录页:
\begin{frame}{目录}
\tableofcontents
\end{frame}
这样就是一个平平无奇固定格式的目录页了

注意这个目录页里面没有刚刚大纲里的最后一项,“参考文献”。因为它被星号隐藏了。
那么如果我们希望只列出一级标题怎么办?方法是使用hideallsubsections参数:
\begin{frame}{目录2}
\tableofcontents[hideallsubsections]
\end{frame}

如果我们希望在每一个章节前都设置一个目录,并且强调当前目录所在的位置,则可以使用currentsection参数选项。
\AtBeginSection[]
{
\begin{frame}{目录3}
\tableofcontents[currentsection]
\end{frame}
}
AtBeginSection命令则指定在每一个章节前显示当前的目录。



如果想要形成和powerpoint类似的逐条显示的效果,可以使用pausesections选项。
\begin{frame}{目录4}
\tableofcontents[pausesections]
\end{frame}



实际上它就是把三页的效果分别保存下来,逐个播放的时候就形成了动画效果。
目录页这部分的总代码归纳如下:
% !TEX program = xelatex
\documentclass[aspectratio=169]{beamer}
\usetheme{AnnArbor}
\usecolortheme{crane}
\usepackage{fontspec}
\usepackage{xeCJK}
\usepackage{tikz}
\setmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setCJKmainfont{AlibabaPuHuiTi-3-55-Regular.ttf}
\setsansfont{Arial}
\setmonofont{Consolas}
\title[中间脚注]{耳东小白的beamer学习测试}
\subtitle{哆哆嗦嗦的历险之旅}
\author[左侧脚注]{耳东小白\inst{1} \and 耳东大白\inst{2}}
\institute[]{\inst{1} 耳东小白工作室 \and \inst{2} 耳东大白工作室}
\date[右侧脚注]{\today}
\titlegraphic{
\begin{tikzpicture}[overlay, remember picture]
\node[left=0.2cm] at (current page.15){
\includegraphics[width = 1cm]{./pics/Logo.png}};
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}{目录}
\tableofcontents
\end{frame}
\begin{frame}{目录2}
\tableofcontents[hideallsubsections]
\end{frame}
\AtBeginSection[]
{
\begin{frame}{目录3}
\tableofcontents[currentsection]
\end{frame}
}
\section{问题描述}
\begin{frame}
这是一个问题!
\end{frame}
\section{现存方法}
\subsection{方法1}
\subsection{方法2}
\subsection{方法3}
\section{对比研究}
\section*{参考文献}
\begin{frame}{目录4}
\tableofcontents[pausesections]
\end{frame}
\end{document}
小结
这是教程的初学部分,包括如何添加封面、标题、作者、logo、如何添加目录等内容。
干货还是不少的,上手也较容易。
教程的接下来部分将会讲到更深入的内容,值得期待。



















