pandoc笔记
pandoc笔记
三星笔记本: win7, pandoc v1.17.2, 默认数据目录 C:\User\xyz\AppData\Roaming\pandoc
. 本机没有, 那就建一个.
pandoc初步
- pandoc在Windows下的安装很简单, 下载, 双击, 一路next即可.
- 试试Demos
pandoc --filter pandoc-crossref --filter pandoc-citeproc --biblio reference.bib --csl chinese-gb7714-2005-numeric.csl --latex-engine=xelatex --template=cqu.latex main.md -o main.pdf
- -s: standalone, 这个是pdf的默认选项,可以不管它。
- -S: smart,几乎也是默认选项,大致可以减少出错概率。
- –filter pandoc-crossref,使用交叉引用插件处理文档。
- –filter pandoc-citeproc,使用文献引用插件处理文档。注意顺序,这个必须在 –filter pandoc-crossref 后面
- –biblio reference.bib 告诉 Pandoc 文献的 bibtex 位置,这里我是直接放在同一目录下的,如在其他目录下,请使用相对路径或绝对路径。
- –csl chinese-gb7714-2005-numeric.csl 告诉 pandoc 使用的文献引用格式,这个 csl 文档直接在 zotero 上找的。
- –latex-engine=xelatex 我没有使用默认的 latex 引擎,而是使用 xelatex 这个引擎。
- –template=cqu.latex 告诉 pandoc 使用模版,这个 cqu.latex 是我在默认模版上修改的。模板可以在这里找到。
- main.md -o main.pdf 告诉pandoc输入文档,-o 告诉 pandoc 输出文档。如果需要转换成别的格式,将 pdf 改成该格式对应后缀名即可。 如转换成 Word 格式,将 pdf 改为 docx;转换成 LaTeX 格式,将 pdf 改为 tex。
- 参考
pandoc -N --toc --columns=10 --latex-engine=xelatex -V CJKmainfont=STSong -V geometry:margin=1in -o test.pdf test.md
- -N 为章节进行数字编号
- –toc 为文档添加目录
- –columns 当不设置时表格的宽度可能有问题,会影响表格的宽度
- –latex-engine=xelatex 设置latex引擎,要想正确的输出中文就得指定xelatex作为引擎
- -V CJKmainfont=STSong 要想正确的输出中文还得指定一个合适的中文字体,这个字体在Centos上须要先安装好
- -V geometry:margin=1in 指定上下左右的空白尺寸
- -o 指定输出文件名
- 参考
记录
从md出发
pdf:
pandoc --latex-engine=xelatex -V mainfont='SimSun' input.md -o output.pdf
在530u3c下是可行的. 2018-2-11在 Pandoc 2.0 版本中,
--pdf-engine
命令取代了原有的--latex-engine
这是一篇好文档, 其中有个st3中的builder, 要弄下来.- tex:
pandoc --latex-engine=xelatex -V mainfont='SimSun' input.md -o output.tex
在三星win7下是可行的. 有几个小问题:- 将
$
转为\(
. - 转换后的
enumerate
环境中多了\tightlist
, 可能与引用的enumitem
宏包有关.
- 将
html:
pandoc -s --mathjax input.md -o output.html
模板
pandoc -D html
查看缺省的模板- 我把模板放在了
C:\Users\tc7200\.pandoc
- 指定模板:
--template=C:/Users/tc7200/.pandoc/template/template.tex
, 不可以改为--template=~/.pandoc/template/template.tex
- 指定设置文件:
-H C:/Users/tc7200/.pandoc/header.js
, 可以改为-H ~/.pandoc/header.js
生成html文件时的header选项 - css文件:
--css=~/.pandoc/css/markdownPad-github.css
md 2 html(latex-engine=xelatex)
\usepackage[boldfont,slantfont,CJKsetspaces,CJKchecksingle]{xeCJK}
中, 要去掉CJKsetspaces.- tightlist
一些舒服的设置
~
指的是C:\users\tc7200\
- 所有的设置(如template, js)都放到同一个地方.
- 命令都写到click.sh中去, 然后点击即可.
https://github.com/zzhi191/pandoc_demo