I am struggling with something simple: I want to generate a word document with a figure and add the figure caption on top (instead of at the bottom of the figure). Please have a look at example at the end of the post where the caption is at the bottom of the plot. I found several examples solving my problem, but they are with latex and pdf output. Any help is appreciated and I suspect this must be a one-liner.
Cheers
---
output:
bookdown::word_document2:
fig_caption: yes
---
```{r, mydoc , echo=FALSE, eval=TRUE}
options(tidyverse.quiet = TRUE)
options(message = FALSE)
library(tidyverse, warn.conflicts = FALSE)
df<-tibble(x=seq(20), y=seq(20))
```{r spending, echo=FALSE,fig.cap="My caption bla bla.",fig.height = 6, fig.width = 12}
ggplot(data = df, aes(x = x, y=y)) +
geom_line()
``
Based on https://bookdown.org/yihui/rmarkdown-cookbook/word-officedown.html, you can use {officedown} like:
which produces something like: