Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 546
Claire Avatar asked Dec 05 '25 10:12

Claire


1 Answers

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

---
output: 
    word_document:
        pandoc_args: ["--smart"]
---
like image 131
tmpname12345 Avatar answered Dec 07 '25 15:12

tmpname12345



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!