阶段 6 · 出版、宏与宏包 45 / 48 ≈ 13 分钟读完

Beamer 教程:一帧一帧做出 LaTeX 幻灯片

beamer 看着像一个只会做幻灯片的文档类,而且一路都按文档类的规矩办事——直到某帧溢出、某个覆盖层跳位、某行 verbatim 解析失败。它其实是一套自带几何、自带页码、自带「什么出现在哪一页」判定规则的演示模型。这一页讲的就是这个模型,外加把它变成能上台的讲稿所需的主题与备注机器。

    一帧是一只盒子,覆盖层是多出来的页

    这个类为每一帧写一页 PDF——更准确地说,是为帧内每一个覆盖层各写一页。一帧里有三处揭示,你放上 \pause 或一个覆盖层标号,beamer 就产出四页,并在书签里给它们同一个名字。模型的全部就是这些:没有动画,也没有阅读器状态,只是页数变多。所以这份 PDF 在任意阅读器里都能放,也所以一份讲稿的页码需要事先想清楚。

    画布不是你挑的纸张尺寸。默认是 12.80cm × 9.60cm;aspectratio=169 换成 16.00cm × 9.00cm;其余具名取值是 43(默认)、32、54、149、1610、141、2013,光秃秃的数字则按比值处理。几何由类给定:左右各一厘米、上下不给、题头再占半厘米。于是 \textwidth 默认 10.8cm、16:9 下 14cm,比 article 的 15.2cm 还窄——从前按厘米量出来的尺寸现在全对不上。

    帧体是先被排进一只盒子、之后才拼成页的。后果有三条:放不下的内容不会重排,只会顶出 Overfull \vbox 并从底部淌出去;帧末那份竖直空白也不是你写的数;而 [t]、[b]、[c](居中,默认)、[s]、[shrink] 这些帧选项管的是盒子摆在哪儿,不是把它缩小。[shrink] 是泄压阀——需要它的帧本该是两帧。

    参考文献、长清单,以及确实要横跨好几页的材料,交给 [allowframebreaks]:它在可断页处切开,并把碎片编号成 1/n、2/n;allowframebreaks=0.9 定的是页要填到多满才允许断,\framebreak 则手动下一刀。注意 allowframebreaks 帧里不许写覆盖层标号,因为 beamer 无从判断某个覆盖层该归到断出来的哪一块。

    Anatomy of a beamer frame: paper size, margins, headline, frame title, body and footline regions 4:3 DEFAULT · PAPER 12.80cm × 9.60cm · GEOMETRY hmargin=1cm, vmargin=0 headline · frame title + navigation symbols body = \textwidth tall block \begin{block}{Claim} … \end{block} everything is inside one box that the frame routine measures; overflow is a warning, not a reflow — that is why “Overfull vbox” means split the frame frametopskip / framebottomskip [t] [b] [c] [s] [shrink] pick the glue footline · page number, section, author short title left margin 1cm = the only horizontal padding beamer adds \paperwidth 12.80cm → \textwidth 10.80cm ASPECT RATIO CHANGES THE CANVAS, NOT THE TYPE aspectratio=169 → 16.00 × 9.00cm \textwidth becomes 14.0cm, \textheight 9.0cm - head font size is untouched, so 16:9 decks look airier: the same \begin{frame} content occupies less width Other keys in the class: 43 (default) · 32 · 54 · 149 · 1610 · 141 · 2013, or any number like 137. WHY MEASURES FROM AN ARTICLE DO NOT TRANSFER article at 10pt: \textwidth ≈ 6in = 15.2cm, margins ≈ 1in + \oddsidemargin beamer: 10.8cm of text on a 12.8cm page — no automatic two-column, no float placement, \linewidth is the frame body \columnwidth = 0.48\textwidth - \columnsep in columns so \includegraphics[width=\linewidth] is right in a column and wrong if you sized it against the paper instead Practical consequence: a figure you tuned in cm for an article must be re-tuned for a deck; size it as a fraction of \linewidth and both survive an aspect-ratio change. Check the geometry of a deck with the frame option [plain] to drop headline and footline while you measure.
    帧的纸幅、页边距与正文盒子各来自哪里,以及为什么 article 量的尺寸搬不过去。

    覆盖层的时间轴:标号与 pause 计数器

    覆盖层标号是限定在一帧内部页码上的区间表达式:<2>、<2-4>、<-3>、<3->、<2,5>、<odd>、<all>。绝对数字数的是这一帧的 PDF 页,于是帧前面多一个 \pause,后面所有数字就集体无声平移。维护上的麻烦全在这里,而 beamer 给的答案是相对写法。

    <+-> 读作「从此往后」,<+> 是「就在这一页」,要偏移就写 <+(1)> 或 <+(-2)>。后面撑着的是计数器 beamerpauses:\pause 给它加一,每遇到一个懂覆盖层的环境也走一步;带 + 的标号读的就是当时的计数。相对标号不怕增删与换序,会长个儿的讲稿都得靠它。

    模式前缀给标号再加一层限定:<all:2->、<beamer:3>、<handout:0>。配上 \begin{frame}<handout:0>,同一份源文件就能投出来是五张、印出来是一页——不必养第二份文件,也就没有复制粘贴带来的漂移。

    还没揭示的材料长成什么样同样可调,而且是全局的:\setbeamercovered{invisible} 是默认,什么都不给看;\setbeamercovered{transparent=15} 留一层一成五的不透明度,让观众先看见后面内容的轮廓;dynamic 与 highly dynamic 则把「下一个」和更远的区别对待。导言区里定一次就够——人们抱怨「跳得难看」,八成说的是这里。

    \underbrace{a_{0} + a_{1}x + a_{2}x^{2} + \cdots}_{\text{the generating function}}
    \underbrace{a_{0} + a_{1}x + a_{2}x^{2} + \cdots}_{\text{the generating function}}
    Overlay time map: which slide number shows which block, and how pause counters and relative specs line up ONE FRAME, FIVE PDF PAGES · THE “SLIDE” NUMBER IS THE COLUMN material 1 2 3 4 5 \only<2>{hint} \visible<3->{proof} \uncover<-2,4>{note} \begin{block}<+->{…} solid = drawn · hatched = typeset but covered, so the space is still reserved · hollow with \only = never even typeset on that slide THE THREE SPEC FORMS THAT DO MOST OF THE WORK <3> <2-4> <-2> <3-> <2,5> absolute: counted in PDF pages of the frame, so a frame that splits shifts every number <+-> <+(1)> <+(-2)> relative to the beamerpauses counter, which \pause and each overlay-aware env advance <all:2-> <handout:1> <beamer> mode-qualified: one deck, two outputs — projected overlays and a flat handout, from one source
    一帧五个覆盖层就是五页 PDF:哪些材料被画出、哪些被盖住、哪些根本没进排版。

    only、alt、visible、uncover、temporal、onslide 到底差在哪

    分界线只有一条:在不需要它的幻灯片上,这份材料到底还排不排。\only<2>{…} 是不排的——其余各页里这些记号在排版之前就被丢掉,既不测量也不留位。换标题时你要的正是这个效果;而第二个覆盖层一到、下面整段文字跳上去的也是它。

    \visible<2->{…} 和 \uncover<2->{…} 在每一页都排版、也都留出位置,区别只在藏的手段。\visible 用 PDF 层面的不可见来画,字形等于不在那儿,连选都选不到;\uncover 把材料交给 \setbeamercovered 配置的那套遮盖机制,transparent 就是从这儿来的。想让版面上那个洞被无声填掉、不留残影,用 \visible;残影本身就是表达的一部分,用 \uncover。

    \alt<2>{this}{that} 二选一,落选那份和 \only 一样不占位;它的环境形式是带四个参数的 altenv,依次是开始、之前、之后、结束。\temporal<2>{before}{during}{after} 属于另一类:三部分永远都排、都量,变的只是样式。所以「当前项高亮、看过的压暗」正是 \temporal 的用武之地,而想插一行文字则不该找它。

    \onslide 是异类:它不吃花括号参数,而是给其后的一切切换遮盖状态;带星号的版本骨子里就是 \only,\onslide+ 则表现得像 \visible。「我这一帧后面怎么没了」这类 bug,多半是本该写 \uncover 的地方写了 \onslide。整块环境有 onlyenv、uncoverenv 和更通用的 actionenv;只想给一片区域上色,用 alertenv 和 structureenv。

    \begin{aligned} f(x) &= x^{2}+1 \\ f'(x) &= 2x \end{aligned}
    \begin{aligned} f(x) &= x^{2}+1 \\ f'(x) &= 2x \end{aligned}
    Comparison of only, alt, visible, uncover, temporal and onslide: is the material typeset, is space reserved, what does it hide behind PICK THE COMMAND BY WHAT YOU NEED THE LAYOUT TO DO command typeset off-spec? space reserved? selectable in the PDF? use it for \only<2>{…} discarded before typesetting no no no swapping one thing for another: titles, labels \alt<2>{a}{b} both read, one chosen one no chosen two different renderings, e.g. compact vs full \visible<2->{…} drawn with PDF invisibility yes yes no nothing at all appears; safe on any background \uncover<2->{…} covered per \setbeamercovered yes yes maybe default is invisible; add transparent=15 to ghost it \temporal<2>{before}{now}{after} all three always typeset yes yes styled colour or weight changes, never for inserting text \onslide<2-> … rest of frame switches a mode, takes no braced group yes yes covered styling whole regions; \onslide* = \only, \onslide+ = \visible The two mistakes this table exists to prevent: \only inside a frame that must keep its height (the block jumps), and \onslide used where a braced group was intended — \onslide does not take a braced argument, it changes the covering state for everything that follows. Environment equivalents when the material is a whole block: onlyenv (like \only), uncoverenv (like \uncover), actionenv for anything that needs an overlay spec.
    六个命令,各自回答同一个问题:不匹配的页上排不排、占不占位、又靠什么把内容藏起来。

    环境、区块与帧上的覆盖层标号

    beamer 把你熟悉的大多数环境重新声明了一遍,好让它们接受尾随标号:\begin{block}<2->{Title},以及 alertblock、exampleblock、theorem 一族、quote、verse、description 和各种列表,名字后面都能跟一个 <spec>。底层用的是 \newenvironment<>——这是 LaTeX 层面的能力:那对 <> 的意思是「读入一个可选的尖括号标号,并以 #1 交出来」,环境再按当前是哪一页决定动作。

    逐例上色的区块与标题来自 \setbeamertemplate{blocks}[rounded][shadow=true],加上 block title/block body 两个颜色钩子;提醒色定在 \setbeamercolor{alerted text}{fg=…},正文里的 \alert{…} 与 \structure{…} 是去查这张颜色表的包装命令,而不是把颜色写死。

    整帧也能带标号——\begin{frame}<1>——只在讲义里出现、或只在某个时刻出现的页就是这么造的。再配上帧标签:\begin{frame}[label{key}] 定一个名字,之后用 \againframe<2>{key} 重新放出其中一层,还可以加一句 \setbeamertemplate{frametitle continuation}[from second] 管住那个「下一部分」后缀。证明先分段揭、末尾再整体回看,标准做法就是这一条。

    帧会自己编号,有时最好别编:[noframenumbering] 把帧从页脚的计数里摘出去(扉页和 \AtBeginSection 生成的过场页都用得上),[plain] 去掉头线与脚线,[environment=…] 则换掉包裹帧体的那层环境——同一份源还要顺带产出一篇论文时,beamerarticle 和自定义主题接的就是这个钩子。

    \frac{1}{2} \le \int_{0}^{1} \frac{\mathrm{d}x}{1+x^{2}} \le 1
    \frac{1}{2} \le \int_{0}^{1} \frac{\mathrm{d}x}{1+x^{2}} \le 1

    脆弱帧:verbatim、listings、TikZ 与 catcode

    普通帧的内容是先当作宏参数读进来、之后才排版的。凡依赖 catcode 的东西都得挂上帧选项 [fragile]:\verb、verbatim 环境、listings 宏包的 lstlisting、自己用了覆盖层标号的 TikZ 图里的 \path<2->,以及含 #、_、% 的代码片段。给了这个选项,beamer 会把帧体写进临时文件,等排版时再带着完好的 catcode 读回来;不给,你拿到的就是那句经典的 Paragraph ended before \beamer@... was complete,或者一段面目全非的代码。

    这份保险是有保费的,值多少得心里有数:脆弱帧不能出现在「帧体必须作为参数」的场合,若干嵌套构造失效,报错也更没参考价值。代码样例请单独开帧,别把整份讲稿都标成 fragile。近亲选项 [containsverbatim] 管得更窄,某些主题里只出现 \verb 时用它就够。

    TikZ 与 pgfplots 值得单开一段。帧里放一张简单的图没事;图在自己的路径上用了覆盖层标号(\node<2->)就必须是脆弱帧,而且 beamer 装的是它那个带 <> 形态的 \newcommand,于是 TikZ \foreach 体里的 #1 得写成双井号。pgfplots 的图很贵:每重画一次都是实打实的计算,几张贴图并用时请走 \usepgfplotslibrary{externalize} 那一类缓存,或者干脆导出一次 PDF 再 \includegraphics——这是 beamer 源文件里对编译时间影响最大的一根杠杆。

    「这一帧坏了但不知道哪儿坏」的排查顺序是:先加 [fragile],再撤覆盖层,再撤区块环境,最后撤图。以帧为单位做最小化比逐行试更快,因为这个类解析的单位本来就是帧。

    % show-me-the-notes.tex
    % presenting:  xelatex show-me-the-notes.tex
    % handout:     xelatex -jobname=handout "\PassOptionsToClass{handout}{beamer}\input{show-me-the-notes}"
    \documentclass{beamer}
    \usetheme{Warsaw}
    \usepackage{mwe}   % example-image-a / -b, so this file compiles as it stands
    
    \setbeameroption{show notes on second screen=right}   % two-page spread per slide
    % \setbeameroption{show only notes}                   % speaker script as a PDF
    % \setbeameroption{hide notes}
    
    \setbeamertemplate{note page}[plain]
    \setbeamerfont{note page}{size=\small}
    
    \begin{document}
    
    \begin{frame}{Sizing graphics against the frame, not the paper}
      \begin{columns}[T]
        \begin{column}{0.45\textwidth}
          \includegraphics[width=\linewidth, height=4.5cm, keepaspectratio]{example-image-a}
    
          \smallskip
          \footnotesize sized against \textbackslash linewidth, so it follows the column
        \end{column}
        \begin{column}{0.5\textwidth}
          \begin{itemize}
            \item \texttt{width=\textbackslash linewidth} follows the column
            \item \texttt{width=0.48\textbackslash textwidth} follows the frame
            \item never \texttt{scale}: it resizes the font too
          \end{itemize}
        \end{column}
      \end{columns}
      \note[item]{First point: the aspect ratio changed the numbers.}
      \note{Second point: \texttt{keepaspectratio} avoids the stretched look.}
    \end{frame}
    
    \begin{frame}<handout:0>{Projector-only aside}
      \only<1>{\includegraphics[width=6cm]{example-image-b}}%
      \only<2->{\includegraphics[width=6cm]{example-image-a}}
    \end{frame}
    
    \end{document}

    骨架:扉页、节、目录、备注与附录

    扉页就是帧里的一句 \titlepage,通常写成 \begin{frame}[plain]\titlepage\end{frame};材料来自 \title、\subtitle、\author、\institute、\date 和 \titlegraphic。每一个都留了短形式的位置——\title[Short]{Long}——而头线与脚线印的正是短形式:短标题不写,等于把长标题在每个页眉重抄一遍。

    节的过场页靠 \section 加一句固定咒语:\AtBeginSection[]{\begin{frame}<beamer>[plain, noframenumbering]\tableofcontents[currentsection]\end{frame}}。\tableofcontents 接受 currentsection、hideothersubsections、pausesections、hideallsubsections;其中 pausesections 会把一帧目录摊成好几帧,讲稿靠它回到大纲,而不是连按出一串一模一样的页。

    演讲备注写 \note{…},可以带覆盖层标号,也可以带 [item] 标签;不主动要求,PDF 里就看不见它们。\setbeameroption{show notes} 在每页后面追加一页备注,show notes on second screen=right 给出为笔记本扩展屏准备的双页跨幅,show only notes 只出讲稿。版式与字号另有 \setbeamertemplate{note page}[plain] 和 \setbeamerfont{note page}{size=\small}。要发一份平铺版,用文档类选项 handout:它把覆盖层压成一页,并丢掉全部备注。

    讲稿的后半场是 \appendix 加一批备用帧,值得认真准备:有人提问、你翻出一张早已备好的页当场作答,是一场报告里收益最高的时刻。被引文献放在最后那一帧 \begin{frame}[allowframebreaks] 里,装 thebibliography 或 \printbibliography;如果主题固执地要在每条前面画个小图标,就补一句 \setbeamertemplate{bibliography item}[text]。

    主题、颜色与模板——改到什么程度不划算

    主题是四个互不隶属的家族:outer(头线、脚线、侧栏、导航)、inner(边距、区块形状、列表符号)、颜色、字体。\usetheme{Madrid} 只是这四类选择的一个打包;你可以按任意粒度混搭 \usecolortheme{whale}、\usefonttheme{serif}、\useoutertheme{infolines}。装好的主题清单不长,值得翻一遍:texdoc beamer 里有逐个说明,而看腻了默认渐变的人会去拿 metropolis(主题名 m),那是现代的扁平方案。

    主题之下,三条命令几乎包办一切。颜色是 \setbeamercolor{normal text}{fg=…, bg=…}——改 bg 是个严肃决定,因为覆盖层和区块都假定背景是实色。结构件是 \setbeamertemplate{itemize items}[square]、{navigation symbols}{}、{frametitle}{…}。字体是 \setbeamerfont{frametitle}{size=\large, series=\bfseries}。至于想留着主题的脚线、只在末尾接一个页码,用 \addtobeamertemplate{footline}{before}{after}。

    有个坑值得点名:只要装了 unicode-math、自定义 \setmainfont,或者 newtx/mathpazo 一族,\usefonttheme{professionalfonts} 就是必选。不写它,beamer 会守住自己的数学字体决定,于是你的字体只管正文不管公式,或者帧标题以古怪字号退回 Computer Modern。顺序是先载字体宏包,再载字体主题。

    几何层面的改动走 \setbeamersize{text margin left=1.2cm, text margin right=1.2cm}:想要横向空间就老实缩页边距,而不是缩字号。其余版面都该按 \linewidth 或 \textheight 的比例给尺寸——这两个数随宽高比变,而一份能从 4:3 直接切到 16:9 不必返工的讲稿,靠的正是从没写死过厘米。

    \zeta(s) = \prod_{p\ \mathrm{prime}} \frac{1}{1 - p^{-s}} \qquad \Re(s) > 1
    \zeta(s) = \prod_{p\ \mathrm{prime}} \frac{1}{1 - p^{-s}} \qquad \Re(s) > 1
    \documentclass{beamer}
    \usetheme{Berlin}
    \usepackage{amsmath}
    
    \begin{document}
    
    \begin{frame}{only / alt / visible / uncover / temporal}
      \only<1>{\textbf{only}: the other slides do not even contain this text.}\\
      \only<2>{\textbf{only} again --- watch the line below jump up.}\\[6pt]
    
      \alt<3>{\textbf{alt}: this branch is typeset}{\textbf{alt}: this one is not}\\[6pt]
    
      \visible<4->{\textbf{visible}: glyphs are drawn invisibly, no copy-paste.}\\[6pt]
    
      \uncover<5->{\textbf{uncover}: covered per \textbackslash setbeamercovered.}\\[6pt]
    
      \temporal<6>{\textcolor{gray}{\textbf{temporal}: before}}
                  {\textcolor{red}{\textbf{temporal}: during}}
                  {\textbf{temporal}: after}
    \end{frame}
    
    \begin{frame}<beamer:0>{This frame exists only in the handout}
      A frame you project nothing of.
    \end{frame}
    
    \begin{frame}<handout:0>{Hidden in the handout, shown when presenting}
      \begin{uncoverenv}<2->
        An environment form: everything inside is subject to the spec.
      \end{uncoverenv}
      \begin{onlyenv}<3>
        Replaced wholesale on other slides, so no space is reserved.
      \end{onlyenv}
    \end{frame}
    
    \begin{frame}[label=slowproof]{A proof in four steps}
      \begin{align*}
        a_{n} &= \frac{1}{n}\sum_{k=1}^{n} x_k \\
        \intertext{hence}
        |a_{n}| &\le \frac{1}{n}\sum_{k=1}^{n} |x_k|
      \end{align*}
      \pause
      and the last line uses boundedness of $(x_k)$.
    \end{frame}
    
    \begin{frame}{Recap}
      Re-showing a labelled frame, with only its second overlay visible:
    \end{frame}
    
    \againframe<2>{slowproof}
    
    \end{document}

    本课速查

    每节抽一行关键代码:点小节名跳到对应位置,代码一键复制。

    小节 关键代码
    \underbrace{a_{0} + a_{1}x + a_{2}x^{2} + \cdots}_{\text{the generating function}}
    \begin{aligned} f(x) &= x^{2}+1 \\ f'(x) &= 2x \end{aligned}
    \frac{1}{2} \le \int_{0}^{1} \frac{\mathrm{d}x}{1+x^{2}} \le 1
    \documentclass{beamer}

    常见错误

    • \verb、lstlisting、verbatim,或者用了覆盖层的 TikZ 图,却把帧写成普通帧。补上 [fragile],帧体才会带着正常的 catcode 被重读,而不是被当成参数抓走。
    • 满篇绝对页号,帧开头多插一个 \pause,后面每个 <4> 一起失效。改用 <+-> 和 <+(1)>,让标号跟着 pause 计数走。
    • 想写 \uncover<2>{…} 却写了 \onslide<2>:\onslide 不吃花括号,于是这份遮盖状态无声罩住帧里剩下的所有东西。
    • 图片尺寸照抄 article 里量好的厘米数。默认 4:3 下帧体宽 10.8cm,16:9 下是 14cm;width=\linewidth 扛得住宽高比切换,定长扛不住。
    • 靠 [shrink] 把一整帧塞进一页。它缩的是盒子,不是你的内容规划;该拆帧就拆,该挪到备用页就挪。
    • 在 [allowframebreaks] 帧里写覆盖层标号:断页机制和覆盖层机制谈不拢,beamer 要么警告,要么直接把标号丢掉。
    • 装了 unicode-math 或自定义正文字体,却没写 \usefonttheme{professionalfonts},然后花一下午查公式为什么还是 beamer 自带的字体。
    • 忘了 \title[short]{long} 和 \author[short]{long} 的短形式,结果每一帧的页眉都在挂完整标题。

    关于本课的常见问题

    beamer 里 only、uncover、visible 有什么区别?
    only 在不匹配的页上把材料直接丢掉,既不排版也不留位,所以版面会跳。uncover 和 visible 都照常排版、都留出位置:visible 让字形在 PDF 里真正不可见,uncover 则交给 \setbeamercovered 配置的遮盖机制——默认是 invisible,写成 transparent=NN 就是留残影。经验法则:一样东西换另一样用 only,其余部分不许动就用 uncover 或 visible。
    为什么我的 beamer 帧报 Paragraph ended before something was complete?
    几乎总是这一帧里有需要 verbatim 式 catcode 的东西:\verb、verbatim 或 lstlisting 环境、带覆盖层标号的 TikZ 路径,或者含 #、_、% 的代码。beamer 读普通帧时把帧体当参数,所以请给帧加上 [fragile] 选项,让它把帧体写进临时文件、再按正常的 catcode 读回。若确实多了一个空行,删掉它是另一种解法。
    怎么把 beamer 幻灯片做成 16 比 9?
    把宽高比选项交给文档类:\documentclass[aspectratio=169]{beamer} 给出 16.00cm × 9.00cm 的画布,\textwidth 也从默认的 10.8cm 变成 14cm。其余具名取值是 43(默认)、32、54、149、1610、141、2013,直接写数字则按比值处理。切换之后,凡是当初用定长和固定字号量过的地方都要复查——画布变大了,字没跟着变大。
    beamer 怎么显示演讲者备注?
    备注写在帧内的 \note{...} 里,观看方式在导言区选:\setbeameroption{show notes} 在每页之后追加一页备注,show notes on second screen=right 为笔记本的演示视图生成双页跨幅,show only notes 只印讲稿。用 handout 选项编译时备注会被整体省略,因此一份源可以同时管投影和打印。
    为什么每一张节的过场页上,beamer 的目录都列出所有节?
    因为裸写的 \tableofcontents 就是把所有东西都印出来。用那些可选键:\tableofcontents[currentsection] 突出当前所在的节,hideothersubsections 与 hideallsubsections 削掉细节,pausesections 一帧揭示一节。整帧塞进 \AtBeginSection[]{...} 里,它就会出现在每一节之前;不想让页脚计数带上它,再加 [plain, noframenumbering]。
    beamer 可以不用演示主题吗?
    可以,而且对一套企业版式来说这常常是正确的起点:只写 \documentclass{beamer},加上 \usetheme{default},再用 \setbeamercolor、\setbeamertemplate 和 \setbeamerfont 去对齐你必须匹配的那几项。主题不过是这三条命令的一堆预设,因此自定义外观意味着覆写它们,而不是抄一份主题文件。一旦你带进自己的正文字体或数学字体,就顺手装上 \usefonttheme{professionalfonts}。

    实时演示:直接编辑 LaTeX,立刻看渲染结果

    预览随输入实时更新——不妨故意写坏一次,看看报错长什么样。

    KaTeX 错误
    试一个例子

    继续读

    同一个东西的三个入口:记法本身、讲它的那一课、以及真正用它写东西的一篇文章。