泰晓科技 -- 聚焦 Linux - 追本溯源,见微知著!
网站地址:https://tinylab.org

泰晓Linux实验盘,即刻上手内核与嵌入式开发
请稍侯

用 Markdown 高效地写幻灯片

Wu Zhangjin 创作于 2015/05/09

By Falcon of TinyLab.org 2015/05/08

背景:笔者用 M$ PowerPoint, Libreoffice Draw, LaTeX 等写过幻灯,没有一个是令人省心的工具,没有一个能让人专注于内容创作本身。繁杂的格式、字体、以及所谓特效调节让人困惑烦恼,自从有了 Markdown,让思绪自由流畅不受阻,让创作回归内容本身,把那些繁杂的演示效果交给其他专业的人士打理就好。】

1 准备环境

1.1 安装pandoc

  • 以Ubuntu为例

    1. sudo apt-get install pandoc
  • 其他平台

    请参考pandoc首页

1.2 安装LaTeX以及中文支持

  • 以Ubuntu为例

    1. $ sudo apt-get install texlive-xetex \
    2. texlive-latex-recommended \
    3. texlive-latex-extra \
    4. latex-cjk-common latex-cjk-chinese \
    5. latex-cjk-chinese-arphic-bkai00mp \
    6. latex-cjk-chinese-arphic-bsmi00lp \
    7. latex-cjk-chinese-arphic-gbsn00lp \
    8. latex-cjk-chinese-arphic-gkai00mp \

1.3 安装Beamer

  • 以Ubuntu为例

    1. sudo apt-get install latex-beamer
  • 相关用法与实例

    1. $ ls /usr/share/doc/latex-beamer/
    2. beameruserguide.pdf.gz
    3. examples
    4. solutions

1.4 安装字体

  1. $ sudo apt-get install \
  2. fonts-arphic-bkai00mp \
  3. fonts-arphic-bsmi00lp \
  4. fonts-arphic-gbsn00lp \
  5. fonts-arphic-gkai00mp \
  6. ttf-wqy-microhei \
  7. ttf-wqy-zenhei

1.5 配置字体

  • 列出可选字体

    1. $ fc-list | egrep "wqy|AR"
  • 实例配置:需配置zh_template.tex如下:

    1. \setCJKmainfont{AR PL KaitiM GB} % 中文字体

2 编写幻灯

2.1 幻灯首页

  • 前三行分别对应

    • 标题
    • 作者
    • 日期
  • 例如:

    1. % Markdown+Beamer+Pandoc幻灯片模板
    2. % 吴章金 @ 泰晓科技 | TinyLab.org
    3. % \today

2.2 幻灯正文

3 格式转换

3.1 生成pdf

  • 利用该模板

    1. $ make pdf & make read
  • 原生命令

    1. $ pandoc -t beamer --toc \
    2. -V theme:Darmstadt \
    3. -V fontsize:9pt \
    4. slides.md -o slides.pdf \
    5. --latex-engine=xelatex \
    6. --template=./templates/zh_template.tex

3.2 生成html

  • 利用该模板

    $ make html & make read-html

  • 原始命令

    1. $ pandoc -t dzslides -s --mathjax \
    2. slides.md -o slides.html

4 实例

4.1 以本文稿为例

  • 下载 Markdown 幻灯模板

    1. $ git clone https://github.com/tinyclub/markdown-lab.git
    2. $ cd markdown-lab/slides/
  • 编译成 pdf & html

    1. $ make
  • 浏览

    1. $ make read & make read-html

5 参考资料



Read Album:

Read Related:

Read Latest: