LaTeX 宏包小记 (1): 用 prosper 制作幻灯片

本文及所附代码, 文件在署名-非商业性使用-相同方式共享 3.0版权协议下发布, 转载请注明出自aifreedom.com

在这个 Blog 里, 我已经写过几篇配置 LaTeX 的文章了, 包括 CJK 宏包字体的配置texlive 2008 的配置. 现在计划开始写一个新的系列, 介绍 LaTeX 里林林总总的宏包(Macro Packages)们.

这个系列的文章不是为对 LaTeX 一无所知的新手写的, 因为我不擅长写入门教程. 但如果你确实需要一本 LaTeX 入门教程, 我极力推荐 “The Not So Short Introduction to LaTeX 2ε”. 在 ctex.org 可以找到它的中文版, “一本不太简短的 LaTeX 2ε 介绍”.

虽说这个系列不是为新手写的, 但它们也不是为那些已经能闭着眼睛就可以用 LaTeX 排出想要的任何效果的高手写的. 这些文章可以看作是我的学习笔记, 而我希望能在 Blog 里同更多和我一样正在努力成为 LaTeX 高手的朋友们分享. 在这些日志里, 我记录下了使用过的一些有趣和/或有用的宏包. 但实话实说, 这些文章都相当没有技术含量. 在我自己看来, 都如白开水一般平淡无味.

在开始正文前, 先废话几句. TeX 和 LaTeX 这两个词究竟该怎么读? Knuth 说 “TeX” 来自希腊单词 “texnologia”(technology) 的第一个音节, 发音为 “Tech”, 就是英文单词 “technology” 的第一个音节. 而 “LaTeX” 的发音是 “Lay-tech” 或 “Lah-tech”. TeX 的伟大不仅仅体现在 Knuth 大神那近乎完美的编码, 更体现在 Knuth 大神为它留下的强大的可扩展能力. LaTeX 就是基于 TeX 开发的一个宏包, 它的出现让 TeX 更平易近人, 使普通人也能轻松地完成高质量的排版.

LaTeX 最常见的用途是用来为学术论文进行排版, 因为它可以清晰地体现文章的逻辑结构, 也可以让作者方便地排版数学公式, 更可以很容易地生成像脚注, 交叉引用, 目录和引用文献这样的复杂结构. 但今天要介绍的宏包 prosper 却是用来生成幻灯片的. 使用 LaTeX 生成幻灯片的优势在于它有 METAFONT, tikz 等这样强大的绘图工具的支持, 在演示逻辑性很强的过程时(比如, 演示最短路的算法时)会相当方便. 但缺点是因为生成的文件是 pdf, 很难有丰富的动画效果.

但我这次使用它却只是”闲得蛋疼”. 这学期的英文写作课上, 我要代表小组做一个 presentation. 在写幻灯片时, 我放弃了 WPS, 转而尝试了一下完全不熟悉的 prosper.

首先, 文档类型要声明为 prosper, 即 \documentclass{prosper}. 在这里可以声明一些参数, 比如是否生成黑白的幻灯片, 使用何种主题等等. 在导言部分可以用 \title, \subtitle, \author, \institution 等命令定义幻灯片的标题, 作者等信息. 然后就可以 \begin{document}, \maketitle 了. 日志的最后有我这次 presentation 的幻灯片和源文件, 不知道我这段话说了什么没关系, 可以参照那个源文件的结构.

每一页幻灯片都是一个 slide 环境, 就是被 \begin{slide}{title} 和 \end{slide} 包围着的一段文字. 在幻灯片里, 可以随意书写文字, 但为了体现演讲的逻辑性, 应该多使用 itemize 和 enumerate 环境.

为了使幻灯片里的条目可以随着演讲者的要求, 一条一条地出现在屏幕上, 在 PowerPoint 里可以使用动画. 但在这里只能让第一张幻灯片上写着第一条, 第二张第二条, 如此产生它们是一条一条出现的伪动画效果了. 当然, 不需要你自己人肉完成这项工作, 但你得告诉 LaTeX 到哪里是第一条, 到那里是第二条.

需要这样效果的部分要用 \overlay{n}{…} 包围起来, 参数 n 是希望分成的页数. 在内容里, 用 \FromSlide{m} 告诉 LaTeX, 我后面的内容从第 m 张幻灯片才开始显示. 比如在下面的这张幻灯片里, 我想让第一级 itemize 每一个 item 依次出现. 于是我在第一个 item 之前加上了 \FromSlide{1}, 在第二个 item 之前加上了 \FromSlide{2}. 效果就是生成的 pdf 里会出现两张幻灯片, 第一张只有第一条, 而第二张上有两条. 类似的标签还有 \UntilSlide{m} 和 \OnlySlide{m}, 它们表达的含义也很明显.

\overlays{2}{
  \begin{slide}{Demerit in First Draft}
    \begin{itemize}
      \FromSlide{1}
    \item Third Supporting Paragraph
      \begin{itemize}
      \item Mere abstract statements
      \item No example supporting the statement of reliability
      \item The only example is for exception
      \end{itemize}
      \FromSlide{2}
    \item Conclusive Paragraph
      \begin{itemize}
      \item Metaphor
      \item But draw it out more
      \item How is the car like comfortable old clothes?
      \end{itemize}
    \end{itemize}
  \end{slide}}

prosper 自带了一些幻灯片的样式, 但它们大多数都让用惯了 PowerPoint 的人不敢恭维. 我用的这个 fyma 算是里面比较清新的一种了. 样式文件可以在 prosper 的安装文件夹里找到, 那些叫做 “PPRxxxx.sty” 的文件都是样式文件了. 想使用哪种样式需要在 documentclass 的选项里声明. 想自定义样式的可以去查一下 prosper 的手册. texlive 2008 里, prosper 的安装路径是 /usr/local/texlive/2008/texmf-dist/tex/latex/prosper

最后, prosper 不支持 pdfLaTeX, 当然也就不支持 xeLaTeX. 所以想要用它生成 pdf 的幻灯片需要使用 “latex slide.tex && dvipdf slide.dvi” 命令. 而且这带来的问题就是如果要生成带中文的幻灯片需要配置 CJK 宏包. 关于 CJK 宏包的设置和中文字体的按照, 可以参见这里.

下面是源文件和编译好的 pdf.

\documentclass[slideColor, pdf, fyma]{prosper}
\title{The Joys of an Old Car}
\subtitle{Cause-Effect Essay}
\author{\textsc{Xie Song} Presents}
\institution{\textsc{Computer Science} 0813\\\textsc{Group} 4}
\newcommand{\ans}[1]{\textbf{Key:} \emph{#1}}
\begin{document}
\maketitle
\overlays{3}{
  \begin{slide}{Demerit in First Draft}
    \begin{itemize}
      \FromSlide{1}
    \item Introductory Paragraph
      \begin{itemize}
      \item Not detailed
      \item How do others comment on the old car?
      \end{itemize}
      \FromSlide{2}
    \item First Supporting Paragraph
      \begin{itemize}
      \item Not persuasive
      \item Provide specific details
      \item How many major repairs?
      \item How good is the gas mileage?
      \end{itemize}
      \FromSlide{3}
    \item Second Supporting Paragraph
      \begin{itemize}
      \item Implicit topic sentence
      \item Too many irrelevant contents
      \item Talk more about her own car
      \end{itemize}
    \end{itemize}
  \end{slide}}

\overlays{2}{
  \begin{slide}{Demerit in First Draft}
    \begin{itemize}
      \FromSlide{1}
      \item Third Supporting Paragraph
        \begin{itemize}
        \item Mere abstract statements
        \item No example supporting the statement of reliability
        \item The only example is for exception
        \end{itemize}
        \FromSlide{2}
      \item Conclusive Paragraph
        \begin{itemize}
        \item Metaphor
        \item But draw it out more
        \item How is the car like comfortable old clothes?
        \end{itemize}
    \end{itemize}
  \end{slide}}

\overlays{4}{
  \begin{slide}{Outline of Final Version}
    \begin{itemize}
      \FromSlide{1}
    \item \textbf{Topic}: The joys of an old car
      \FromSlide{2}
    \item \textbf{Thesis}: The old car has opened my eyes to rewards
      of owning an old car
      \FromSlide{3}
    \item \textbf{Reason I}: My old Toyota is \emph{economy}
      \FromSlide{4}
      \begin{itemize}
      \item Shiny red year-old leftover, for a mere \emph{\$4,200}
        then, but it is \emph{4 times} cost now
      \item Save money on insurance for being not worthwhile
      \item Only \emph{three} major repairs in the last several years
      \item Good gas mileage: \emph{28 miles/gal} in city and \emph{41 miles/gal} on highway
      \end{itemize}
    \end{itemize}
  \end{slide}}

\overlays{2}{
  \begin{slide}{Outline of Final Version}
    \begin{itemize}
      \FromSlide{1}
    \item \textbf{Topic}: The joys of an old car
    \item \textbf{Thesis}: The old car has opened my eyes to rewards
      of owning an old car
    \item \textbf{Reason I}: My old Toyota is \emph{economy}
    \item \textbf{Reason II}: My old Toyota is \emph{dependable}
      \FromSlide{2}
      \begin{itemize}
      \item A Toyota that passes the \emph{20,000-mile mark} with no problems
        will probably go on forever
      \item When Boss got stuck with \emph{brand-new BMW} in the \emph{worst snowstorm},
        I sauntered into work on time
      \item The single time Toyota didn't start was a final exam day
      \item Body of an old car, the engine of a teenager
      \end{itemize}
    \end{itemize}
  \end{slide}}

\overlays{2}{
  \begin{slide}{Outline of Final Version}
    \begin{itemize}
      \FromSlide{1}
    \item \textbf{Topic}: The joys of an old car
    \item \textbf{Thesis}: The old car has opened my eyes to rewards
      of owning an old car
    \item \textbf{Reason I}: My old Toyota is \emph{economy}
    \item \textbf{Reason II}: My old Toyota is \emph{dependable}
    \item \textbf{Reason III}: Having the same car for many years offers the
      advantage of \emph{familiarity}
      \FromSlide{2}
      \begin{itemize}
      \item Like a well-worn glove
      \item Know to the \emph{millimeter} exactly how much room when turning
        a corner or back into a curbside parking space
      \item Gas ``empty'' means \emph{1.3 gallons} are still in
        reserve
      \item Front wheels invariably shake when going more than \emph{55%
          miles/h}
      \item The only surprises come from other drivers
      \end{itemize}
    \end{itemize}
  \end{slide}}
\part{\huge Thanks for your time!}

\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
0 0 votes
Article Rating
Subscribe
Notify of
guest
16 Comments
Inline Feedbacks
View all comments
layla
13 years ago

一觉醒来竟然还能抢到沙发…

Ariesbear
13 years ago

原来是proser。前段时间看了beamer的文档,感觉自带的样式还是太简陋。TeX的读音以前一直搞错,特地查了一下发现GNOME和Qt的读音可能也有很多人搞错的说

Ariesbear
13 years ago
Reply to  aifreedom

gnome在英语中“g”不发音,不过现在很多开发人员也读/gəˈnoʊm/。Qt官方发音是“cute”

yaker
yaker
13 years ago

prosper,标题错了~

bigclean
13 years ago

还是更喜欢beamer多一些,感觉自带的theme很漂亮,而且切换效果可以做的很如ppt,很炫目,texpower没有试过。prosper不能支持xelatex很不方便,虽然也有配置中文字体,现在也是懒得一直只用xelatex+xeCJK了。

soho一族
13 years ago

来点非技术的吧……

Uping
Uping
13 years ago

赞~ :mrgreen:

锐智博客
13 years ago

学习啦

Tanky Woo
13 years ago

无限膜拜。。。
大牛有没有介绍自己ACM经验的文章?

华科的大牛就是厉害。。。曾经还想考这个学校的。。。奈何分数差了一点。。。我也是08级的。Orz

zhiqiang
13 years ago

我以前也用过latex写ppt,后来发现实在是太受虐了。

28fw
13 years ago

写得很详细,顶一下

AB先生博客
AB先生博客
13 years ago

55大侠们 按上面步骤还是没有解决掉?

trackback

[…] 还记得去年因为答应过 Layla, 半夜起来更新博客(应该是这篇). 时间越用越紧, ToDo List 却越来越长. Google Reader 也少用了, […]

16
0
Would love your thoughts, please comment.x
()
x