问题
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.
- 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
- 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