Claire
Claire

Reputation: 33

How to get rmarkdown and knitr to use em-dash with .docx files?

I am new to using rmarkdown and knitr to produce .docx word documents. The rmarkdown reference guide states that using -- gives an en-dash, and --- gives an em-dash.

If I knit my .Rmd file to HTML then the en-dashes and em-dashes are working correctly, however when knitting to a word document, they remain as -- and ---.

I am using Microsoft Word 2013, and I have checked the autoformatting options are set to replace hyphens with a dash.

Any help would be very much appreciated, thanks!

Upvotes: 3

Views: 1733

Answers (1)

tmpname12345
tmpname12345

Reputation: 2921

You need to add a pandoc_args: ["--smart"] to the header: Then it words for DocX format

---
output: 
    word_document:
        pandoc_args: ["--smart"]
---

Upvotes: 5

Related Questions