MAC下利用pandoc+markdown来写slide

作者: CqrxFZ | 来源:发表于2015-02-17 00:38 被阅读3949次

% MAC下利用pandoc+markdown来写slide
% 胡浩源 haoyuan.huhy@gmail.com
% 2015年1月16

Mac下用markdown+markdown写slide

WHY

写一份markdown文件, 根据需要可以生成:

  • slide pdf
  • document pdf
  • slide html

安装

brew install pandoc
brew tap phinze/cask
brew install brew-cask
brew cask install mactex

源码

# today

## morning
- I want to have breakfast

## afternoon
- I want to have lunch

PDF

pandoc -D latex > mytemplate.tex
pandoc test.md -o test.pdf -t beamer 
--latex-engine=xelatex 
--template=mytemplate.tex

直接执行是不成功的。

增加中文字体配置

修改mytemplate.tex

\ifxetex
\usepackage{hyperref}
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\usepackage{xeCJK}
\setCJKmainfont[BoldFont = Hiragino Sans GB W6]{Hiragino Sans GB W3}
\setCJKsansfont[BoldFont=SimHei]{SimHei}
\setCJKmonofont{SimHei}
\else
\usepackage[unicode=true]{hyperref}
\fi

html5

  • DZSlides
  • Slidy
  • S5
  • Slideous
  • reveal.js

reveal.js

git clone https://github.com/hakimel/reveal.js

pandoc slides.md -o slides.html -t revealjs 
-s -V theme=beige

这样是执行不成功的

fix

不要用reveal 3.0, 用reveal.js 2.6

reveal.js背景

  • default:(默认)深灰色背景,白色文字
  • beige:米色背景,深色文字
  • sky:天蓝色背景,白色细文字
  • night:黑色背景,白色粗文字
  • serif:浅色背景,灰色衬线文字
  • simple:白色背景,黑色文字
  • solarized:奶油色背景,深青色文字

Makefile

利用makefile来自动化构建

slide:${f}
    pandoc ${f} -o pdf_slide/${f}.pdf -t beamer --latex-engine=xelatex --template=./mytemplate.tex

pdf:${f}
    pandoc ${f} -o pdf_doc/${f}.pdf  --latex-engine=xelatex --template=./mytemplate.tex

reveal:${f}
    pandoc ${f} -o html_slide/${f}.html -t revealjs -s -V theme=beige

all:${f} slide pdf reveal
    echo "ok"

print:${f}
    echo ${f}

make usage

make slide f=pandoc_setup.md 
make pdf f=pandoc_setup.md 
make reveal f=pandoc_setup.md 

文件结构

.
├── Makefile
├── html_slide
│   ├── pandoc_setup.md.html
│   └── reveal.js
├── mytemplate.tex
├── pandoc_setup.md
├── pdf_doc
│   └── pandoc_setup.md.pdf
└── pdf_slide
    └── pandoc_setup.md.pdf

20161027

  • 新版的mac, tex的路径有所变化:/Library/TeX/texbin/,这个需要加入path

20161103

  • 生成的图片大小过大, 查询pandoc预发文档, 利用示例的{width=200px}语法并不生效
  • 通过修改css文件内对应theme beige的img属性, 从95%调整为60%解决。

thanks

gitlab地址

相关文章

网友评论

  • 老麦的砖头:brew install brew-cask 改成 brew install brew-cask-completion 就可以了
  • 老麦的砖头:No available formula with the name "brew-cask
  • 87b0675cbb29:你好。我想问下再转换PDF的时候他不会自动换行,这个问题出在哪里
    我在brew上装的pandoc,然后之前看的另一个教程装的basiclatex和xecjk

本文标题:MAC下利用pandoc+markdown来写slide

本文链接:https://www.haomeiwen.com/subject/hbryxttx.html