I'm trying to create a table with a fairly long caption that I'd like to print beneath the table. When I use the pandoc.table
function in the package pander
, I can get this to work as long as I'm content with seeing the raw markdown output as rendered in R:
```{r cars}
pandoc.table(head(cars), caption="Where the hell does the caption go",
style="multiline")
```
but as soon as I specify results='asis'
so that knitr
renders it prettily in whatever output format I've selected (html, pdf, or word), the caption moves to the top of the table:
```{r cars2, results='asis'}
pandoc.table(head(cars), caption="Where the hell does the caption go",
style="multiline")
```
This is especially interesting as all the other SO questions on the topic that I can find are several years old, and are from people who were looking to go the other way (move captions from the bottom to the top). So clearly some default setting has been changed!
I have tried modifying the .docx template and so far that hasn't helped - there doesn't seem to be a place to modify the default table caption location (and indeed when I work in other documents, the default actually seems to be the bottom anyway). The fact that it happens in pdf and html output too makes me think I need to modify something on the RStudio end, but I can't see where.
I'm not wedded to the pandoc.table() world, but I am wedded to Word, which rules out some other options (xtable
, the fun stuff in kableExtra
).
Versions: R 3.4.1 x86_64 ("Single Candle"), RStudio 1.0.143, pander 0.6.1.