4
votes

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.

1
The placement of the caption in the markdown file has no effect on where the caption will be rendered in the resulting docx file. It was rendered below the table with pandoc and there were no way to change this behavior, but it was updated recently -- so just update pandoc to 1.13.2.1+ and keep using (R)markdown :)daroczig

1 Answers

4
votes

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.