Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

28.4. Markdown 转 Office 文档

28.4.1. Office 制作模版

从已存在文件制作模版

			
pandoc -o template.docx --print-default-data-file reference.docx
pandoc -o template.pptx --print-default-data-file reference.pptx
			
			

输出文件

			
pandoc -f markdown -t docx --reference-doc=template.docx -o test.docx test.md
pandoc -f markdown -t pptx --reference-doc=template.pptx -o test.pptx test.md
			
			

早起 office 使用 dotx 和 potx

			
pandoc -o template.dotx --print-default-data-file reference.docx
pandoc -o template.potx --print-default-data-file reference.pptx
			
			

输出文件

			
pandoc -f markdown -t docx --reference-doc=template.dotx -o test.docx test.md
pandoc -f markdown -t pptx --reference-doc=template.potx -o test.pptx test.md
			
			

28.4.2. Word 目录

目录参数 --toc

目录深度 --toc-depth=3

			
pandoc -f markdown -t docx --reference-doc=template.dotx --toc --toc-depth=3 -o test.docx test.md
			
			

设置目录标题

			
pandoc input.md -o output.docx --toc -M toc-title="目录" title="SSS"
			
			

参考文献

			
pandoc --citeproc --number-sections \
--csl gb-t-7714-2015-numeric-bilingual-no-uppercase-no-url-doi.csl \
--bibliography ref.bib -M reference-section-title="参考文献" \
-M link-citations=true --reference-doc=ref.docx -s input.md -o main.docx			
			
			

28.4.2.1. 设置目录标题

				
---
toc-title: "内容目录"
lang: zh-CN
---				
				
				

28.4.2.2. 标题和作者

方案一

				
neo@netkiller neo % pandoc -f markdown -t docx --reference-doc=../template/template.dotx --toc --toc-depth=3  -M toc-title="目录" -M title="文档标题" -o test.docx test.md				
				
				

方案二,向 markdown 文件中添加声明

				
---
title:  'This is the title: it contains a colon'
author:
- Author One
- Author Two
keywords: [nothing, nothingness]
abstract: |
  This is the abstract.

  It consists of two paragraphs.
---
				
				

28.4.3. PPT 幻灯片大纲深度

			
pandoc -f markdown -t pptx --reference-doc=template.potx --slide-level=2 -o test.pptx test.md