如何指定使用 pandoc 导出的 word doc 使用的字体? [英] How to specify the font used for word doc exported using pandoc?
问题描述
使用pandoc渲染Microsoft Word文档.字体的标题似乎默认为 Calibri ,正文文本默认为 Cambri .目标是使文件使用Arial或Times罗马字体.
Rendering a microsoft word document using pandoc. The font seems to default to Calibri for headings and Cambri for body text. Goal is to have the file use Arial or Times roman fonts.
我不想用文字触摸/编辑/与文件有任何关系.
I don't want to touch/edit/have anything to do with the file in word.
如何从多重降价来源或 pandoc的调用中设置将在Word™中使用的字体?
How can I set the font that will be used in Word™ from either the multi-markdown source or in the call to pandoc?
Pandoc命令:
pandoc -s my_markdown.txt -o whycambriafont.docx
此问题: pandoc生成的docx缺少方程式中的斜体变量显示了一种通过创建一个zip文件然后编辑样式文件来编辑字体样式的方法,但这很麻烦.
This question: pandoc-generated docx misses italic variables in equations shows a way to edit the font styles by creating a zip and then editing the style files, but is a kludge.
推荐答案
You can supply a reference.docx file with the --reference-doc option to pandoc which acts sort of like a template.
- 使用
echo'hello word'生成文件|pandoc -o reference.docx
或类似的文件. - 更改样式中的字体.通过在Word中打开文件,更改样式并保存它,或者例如使用
vim
打开它:- 将
reference.docx
重命名为reference.zip
-
vim reference.zip
并选择reference/theme/theme1.xml
- 找到并将
Calibri
更改为Arial
- 保存并将zip重命名为docx
- 将
- Generate a file with
echo 'hello word' | pandoc -o reference.docx
or similar. - Change the font in the style. Either by opening the file in Word, changing the style and saving it, or alternatively opening it for example with
vim
:- Rename the
reference.docx
toreference.zip
vim reference.zip
and selectreference/theme/theme1.xml
- find and change
Calibri
toArial
- save and rename zip back to docx
- Rename the
另请参见定义-custom-DOCX样式在LibreOffice中(和Word).
这篇关于如何指定使用 pandoc 导出的 word doc 使用的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!