rstudioknitrcaption.docpander

Put table captions on top when knitting Word .doc with R markdown


Table captions are positioned below the table when using R markdown to knit a Word document in RStudio. I need the table captions above the table.

I have tried the kable() and pander() functions without success.

A solution using xtable() when knitting .pdf can be found here: How to make RMarkdown (.Rmd) table captions go at the top

However, to my knowledge xtable() is not compatible when knitting to Word .doc.

The capability for this option was downplayed in How to position and format length of a table's title [R Markdown, pander package] due to pandoc policy of table captions on bottom. My recent visits to the pandoc documentation indicate that this policy has been rescinded.

I would like to continue using R markdown to knit Word documents, but will have to abandon if table captions remain below the table.


Solution

  • Based on the comment by daroczig, I was able to reach solution by installing the latest version of pandoc using the following commands in R:

    library(installr)
    install.pandoc()
    

    Note that reinstalling latest version of RStudio did not update pandoc. This solution works with R 3.2.2; install.pandoc() had an error with R 3.1.3 and installing pandoc manually (ie. from outside R using the msi file) did not fix the problem.