% !TeX program = lualatex
\documentclass[aspectratio=169,9pt,t]{beamer}
\usepackage[UTF8,fontset=fandol]{ctex}
\usetheme{LZU}
\usetikzlibrary{arrows.meta,automata,positioning}

\title{Beamer-LZU}
\subtitle{基于 LaTeX Beamer 的兰州大学幻灯片模板}
\author{示例报告人}
\institute{兰州大学信息科学与工程学院}
\date{\today}

\begin{document}
\maketitle
\lzuoutline

\section{LaTeX 与 Beamer}
\subsection{LaTeX}
\begin{frame}{LaTeX}
  正文、公式和引用都可以写进同一个源文件。修改章节顺序后，重新编译即可更新目录和导航。

  \medskip
  例如，行内公式 \(e^{i\pi}+1=0\) 随正文排版，行间公式则单独居中。
  \[
    \int_0^1 x^2\,\mathrm{d}x=\frac{1}{3}.
  \]
\end{frame}

\subsection{Beamer}
\begin{frame}{Beamer}
  一张逻辑幻灯片写在一个 \texttt{frame} 环境中。它可以包含多个逐步显示的画面，共用同一个帧号。

  \medskip
  点击页眉的章节标题可跳到章节页，点击圆点可跳到对应的正文帧。
  叠加显示的写法见 Beamer 手册\cite{beamer}。
\end{frame}

\section{幻灯片动画}
\subsection{逐步显示}
\begin{frame}{怎样比较两种算法的耗时？}
  用同一批输入测试算法 A 和 B。
  \begin{enumerate}
    \setlength{\itemsep}{.85em}
    \item<1-> \textbf{先测基线。} 用算法 A 处理这批输入，记录每次运行的耗时。
    \item<2-> \textbf{再换算法。} 保持输入、机器和计时方法一致，改用算法 B。
    \item<3-> \textbf{逐对比较。} 对每个输入计算 \(t_A-t_B\)，正值表示 B 更快。
  \end{enumerate}
  \note{揭示第二步前，先请听众说出需要保持不变的条件。}
\end{frame}

\subsection{揭示答案}
\begin{frame}{哪一次测量最接近典型耗时？}
  同一程序运行了三次。若用中位数描述典型耗时，应选哪一个读数？
  \[
    2.1\,\mathrm{s} \qquad 9.8\,\mathrm{s} \qquad 2.0\,\mathrm{s}
  \]
  \visible<2->{%
    \textbf{按耗时排序}\quad
    \(2.0 < \alert{2.1} < 9.8\)\par\smallskip
    居中的读数是 \(2.1\,\mathrm{s}\)，来自第一次测量。}
\end{frame}

\subsection{切换内容}
\begin{frame}{每收到一个样本，均值怎样变化？}
  三个样本按顺序到达。每一步用已到达的样本重新计算均值。
  \begin{center}
    \renewcommand{\arraystretch}{1.35}
    \begin{tabular}{@{}lccc@{}}
      采样次序 & 第一次 & 第二次 & 第三次 \\
      观测值 & \(2\) & \visible<2->{\(4\)} & \visible<3->{\(6\)}
    \end{tabular}
  \end{center}
  % overprint measures the largest alternative; all three share one origin.
  \begin{overprint}
    \onslide<1|handout:0>
      当前均值\quad \(\displaystyle \vphantom{\frac{2+4}{2}}\bar x_1 = 2\)
    \onslide<2|handout:0>
      当前均值\quad \(\displaystyle \bar x_2 = \frac{2+4}{2} = 3\)
    \onslide<3|handout:1>
      当前均值\quad \(\displaystyle \bar x_3 = \frac{2+4+6}{3} = 4\)
  \end{overprint}
\end{frame}

\subsection{公式推导}
\begin{frame}{从乘积推导完全平方公式}
  将两个相同的因式相乘。
  \[
    \begin{aligned}
      (x+1)^2 & = (x+1)(x+1) \\[.5em]
              & \visible<2->{= x^2+x+x+1} && \visible<2->{\text{展开乘积}} \\[.5em]
              & \visible<3->{= x^2+2x+1}  && \visible<3->{\text{合并同类项}}
    \end{aligned}
  \]
\end{frame}

\section{矢量图与排版}
\subsection{几何作图}
\begin{frame}{用面积解释完全平方公式}
  边长为 \(x+1\) 的正方形可以分成哪几块？设 \(x>0\)。
  \medskip
  \begin{columns}[c,onlytextwidth]
    \begin{column}{.42\textwidth}
      \centering
      \begin{tikzpicture}[x=.83cm,y=.83cm,draw=LZUBlue]
        \path[use as bounding box] (-.6,-.2) rectangle (4.2,4.45);
        \fill[LZUBlue!15] (0,0) rectangle (3,3);
        \node at (1.5,1.5) {\(x^2\)};
        \only<2->{%
          \fill[LZUBlue!35] (0,3) rectangle (3,4);
          \fill[LZUBlue!35] (3,0) rectangle (4,3);
          \node at (1.5,3.5) {\(x\)};
          \node at (3.5,1.5) {\(x\)};}
        \only<3->{%
          \fill[LZUBlue!70] (3,3) rectangle (4,4);
          \node[text=white] at (3.5,3.5) {\(1\)};}
        \draw (0,0) rectangle (4,4) (0,3) -- (4,3) (3,0) -- (3,4);
        \node[above] at (1.5,4) {\(x\)};
        \node[above] at (3.5,4) {\(1\)};
        \node[left] at (0,1.5) {\(x\)};
        \node[left] at (0,3.5) {\(1\)};
      \end{tikzpicture}
    \end{column}
    \begin{column}{.54\textwidth}
      左下方块的面积为 \(x^2\)。\par\medskip
      \visible<2->{两块长方形各占 \(x\)，合计 \(2x\)。}\par\medskip
      \visible<3->{小正方形再补上 \(1\)。\par\medskip
        \(\displaystyle (x+1)^2=x^2+2x+1\)}
    \end{column}
  \end{columns}
\end{frame}

\subsection{状态图}
\begin{frame}{打开的文件怎样到达关闭状态？}
  \begin{center}
    \begin{tikzpicture}[>=Stealth,font=\small,
        state/.style={circle,draw=LZUBlue,fill=LZUBlue!9,minimum size=1.35cm},
        every edge/.style={draw=LZUBlue,->}]
      % The canvas and node positions stay fixed as transitions are added.
      \path[use as bounding box] (-2,-1.5) rectangle (6.3,1.65);
      \node[state] (reading) at (0,0) {reading};
      \draw[->,LZUBlue] (-1.9,0) -- node[above]{open} (reading);
      \path (reading) edge[loop above] node{read} (reading);
      \only<2->{%
        \node[state] (eof) at (2.7,0) {eof};
        \path (reading) edge node[above]{EOF} (eof);}
      \only<3->{%
        \node[state] (closed) at (5.4,0) {closed};
        \path (eof) edge node[above]{close} (closed)
              (reading) edge[bend right=28] node[below]{close} (closed);}
    \end{tikzpicture}
  \end{center}
  \begin{overprint}
    \onslide<1|handout:0>成功读取数据后，文件仍处于可读状态。
    \onslide<2|handout:0>读取操作返回 EOF 时，文件到达末尾。
    \onslide<3|handout:1>两条关闭路径都有效。文件可以在读取途中关闭，也可以在到达末尾后关闭。
  \end{overprint}
\end{frame}

\subsection{定理与证明}
\begin{frame}{定理与证明}
  \begin{theorem}
    任意奇数的平方仍为奇数。
  \end{theorem}
  \begin{proof}
    设 \(n=2k+1\)，其中 \(k\in\mathbb Z\)。则
    \[
      n^2=4k^2+4k+1=2(2k^2+2k)+1.
    \]
    因此 \(n^2\) 可写成一个偶数加一。
  \end{proof}
\end{frame}

\section{其他功能}
\subsection{双栏布局}
\begin{frame}{双栏布局}
  \begin{columns}[T,onlytextwidth]
    \begin{column}{.46\textwidth}
      \textbf{实验设置}\par\medskip
      固定输入规模，对同一个程序重复计时三次。每次计时前恢复相同的初始状态。
    \end{column}
    \begin{column}{.46\textwidth}
      \textbf{测量结果}\par\medskip
      \begin{tabular}{@{}lrrr@{}}
        次数 & 1 & 2 & 3 \\ \hline
        耗时（秒） & 2.1 & 1.9 & 2.0
      \end{tabular}
      \par\medskip 平均耗时为 \(2.0\) 秒。
    \end{column}
  \end{columns}
\end{frame}

\subsection{内容跨页}
\begin{frame}[allowframebreaks]{内容跨页}
  \linespread{1.5}\selectfont
  \setlength{\parskip}{.5em}
  \textbf{王勃《滕王阁序》节选}\par\medskip
  豫章故郡，洪都新府。星分翼轸，地接衡庐。襟三江而带五湖，控蛮荆而引瓯越。物华天宝，龙光射牛斗之墟；人杰地灵，徐孺下陈蕃之榻。

  披绣闼，俯雕甍，山原旷其盈视，川泽纡其骇瞩。闾阎扑地，钟鸣鼎食之家；舸舰弥津，青雀黄龙之舳。云销雨霁，彩彻区明。落霞与孤鹜齐飞，秋水共长天一色。渔舟唱晚，响穷彭蠡之滨，雁阵惊寒，声断衡阳之浦。

  遥襟甫畅，逸兴遄飞。爽籁发而清风生，纤歌凝而白云遏。睢园绿竹，气凌彭泽之樽；邺水朱华，光照临川之笔。四美具，二难并。穷睇眄于中天，极娱游于暇日。天高地迥，觉宇宙之无穷；兴尽悲来，识盈虚之有数。望长安于日下，目吴会于云间。地势极而南溟深，天柱高而北辰远。关山难越，谁悲失路之人；萍水相逢，尽是他乡之客。怀帝阍而不见，奉宣室以何年？

  嗟乎！时运不齐，命途多舛。冯唐易老，李广难封。屈贾谊于长沙，非无圣主；窜梁鸿于海曲，岂乏明时？所赖君子见机，达人知命。老当益壮，宁移白首之心？穷且益坚，不坠青云之志。酌贪泉而觉爽，处涸辙以犹欢。北海虽赊，扶摇可接；东隅已逝，桑榆非晚。孟尝高洁，空余报国之情；阮籍猖狂，岂效穷途之哭！

  勃，三尺微命，一介书生。无路请缨，等终军之弱冠；有怀投笔，慕宗悫之长风。舍簪笏于百龄，奉晨昏于万里。非谢家之宝树，接孟氏之芳邻。他日趋庭，叨陪鲤对；今兹捧袂，喜托龙门。杨意不逢，抚凌云而自惜；钟期既遇，奏流水以何惭？

  呜呼！胜地不常，盛筵难再；兰亭已矣，梓泽丘墟。临别赠言，幸承恩于伟饯；登高作赋，是所望于群公。敢竭鄙怀，恭疏短引；一言均赋，四韵俱成。请洒潘江，各倾陆海云尔。

  \begin{center}
    滕王高阁临江渚，佩玉鸣鸾罢歌舞。\\
    画栋朝飞南浦云，珠帘暮卷西山雨。\\
    闲云潭影日悠悠，物换星移几度秋。\\
    阁中帝子今何在？槛外长江空自流。
  \end{center}

\end{frame}

\appendix
\begin{frame}{附注}
  放映时可直接使用生成的 PDF。需要讲义时，在文档类选项中加入 \texttt{handout}，即可合并逐步显示的内容。互相替换的内容可以用 \texttt{handout:} 指定保留哪一步。
\end{frame}

\begin{frame}{参考文献}
  \begin{thebibliography}{9}
    \bibitem{beamer} Till Tantau 等，\emph{The Beamer Class User Guide}。
      \href{https://ctan.org/pkg/beamer}{CTAN 软件包主页}。
    \bibitem{touying} Oscar Tuo，\emph{Touying-LZU}，v0.1.1。
      \href{https://mirrors.lzu.edu.cn/github-release/touying-lzu/v0.1.1/}。
  \end{thebibliography}
\end{frame}
\lzuend{感谢聆听\\[.6em]Thanks for Listening!}
\end{document}
