How to specify the font used for word doc exported using pandoc?

ぃ、小莉子 提交于 2020-06-11 20:05:51

问题


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.

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 command:

pandoc -s my_markdown.txt -o whycambriafont.docx

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.


回答1:


You can supply a reference.docx file with the --reference-doc option to pandoc which acts sort of like a template.

  1. Generate a file with echo 'hello word' | pandoc -o reference.docx or similar.
  2. 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 to reference.zip
    • vim reference.zip and select reference/theme/theme1.xml
    • find and change Calibri to Arial
    • save and rename zip back to docx
  3. Profit: use with pandoc --reference-doc reference.docx

See also Defining-custom-DOCX-styles-in-LibreOffice-(and-Word).



来源:https://stackoverflow.com/questions/34600141/how-to-specify-the-font-used-for-word-doc-exported-using-pandoc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!