2

I am trying to learn Basics of Markdown and Pandoc to speed up my academic writing.

I would like to ask whether it possible to define font family and font size, when converting from Markdown (.md) file to Word-2016 (.docx) file? I tried two methods:

  1. I added
---
mainfont: "Palatino"
---

to the *.md file.

  1. I tried to add -- variable mainfont="Palatino" to the command line when converting files.

Neither method produces desired font change. Could anyone advise on the proper method of setting the font, if it is possible to do so during the conversion procedure?

Edit: I have followed guidelines presented in the article "Sustainable Authorship" on programminghistorian.org, where they suggest using mainfont: times in YAML. I would like to know why it is not working for me. My question is not duplicate, I do not need different fonts/styles for text body and headings. I need to have everything uniformly converted into "Arial" or "Palatino". Edit: I have tried to create a reference .docx file, however, I cannot understand how to make changes to the reference file, so these changes are implemented when Pandoc converting my markdown to .docx.

user136555
  • 255
  • 2
  • 11
  • you've seen https://pandoc.org/MANUAL.html ? – mb21 Jun 02 '20 at 13:34
  • My problem is how to modify a .docx reference style file, which can be used by pandoc to style my markdown. One has to be a Microsoft Word power user to create a decent style file. – user136555 Jun 04 '20 at 06:43
  • Does this answer your question? [How to specify the font used for word doc exported using pandoc?](https://stackoverflow.com/questions/34600141/how-to-specify-the-font-used-for-word-doc-exported-using-pandoc) – mb21 Jun 04 '20 at 07:02
  • I have seen this Answer. My problem is here: "Change the font in the style. Either by opening the file in Word, changing the style and saving it". I had to go to Microsoft Word manuals to find out how to apply the changes to the "reference" .docx file. This is my problem. – user136555 Jun 05 '20 at 04:25

1 Answers1

2

As mentioned in the MANUAL, the mainfont variable doesn't work for docx output, only PDF/LaTeX/ConTeX etc..

For Word, you need to use the --reference-doc option.

See also https://stackoverflow.com/a/34609460/214446

mb21
  • 34,845
  • 8
  • 116
  • 142
  • I tried the `--reference-doc` and it did not change the font either – WestCoastProjects Apr 25 '23 at 16:01
  • @WestCoastProjects did you read the link? "To produce a custom reference.docx, first get a copy of the default reference.docx: pandoc -o custom-reference.docx --print-default-data-file reference.docx. Then open custom-reference.docx in Word, modify the styles as you wish, and save the file. For best results, do not make changes to this file other than modifying the styles used by pandoc" – mb21 Apr 26 '23 at 06:59
  • Yes i did all that including trying different font sizes in there 8 9 10 – WestCoastProjects Apr 26 '23 at 18:16