rr-markdownflextableofficedown

Why is the flextable caption different from the data.frame caption in officedown::rdocx_document outputs?


When knitting the below code to an officedown::rdocx_document the output does not show the front part of the caption of Table 2: in bold face, while it does show the equivalent parts of the other table and figure captions in bold face. Also notice that the numbers in the references at the very botton are equally different.

Can someone explain why a flextable output is being treated differently than a data.frame output and how can I manage to make them all look the same? That is, all figure and table captions.

Library versions:
flextable 0.6.6
officedown 0.3.0
magrittr 2.0.3 (probably not relevant)

---
title: "officedown template"
output: 
  officedown::rdocx_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.cap = TRUE, echo = FALSE)
library(officedown)
library(magrittr)
```

## Tables

```{r tab.cap="the mtcars data", tab.id="mtcars-data"}
head(mtcars)
```

```{r tab.cap="the iris data", tab.id="iris-data"}
head(iris) %>%
  flextable::flextable()
```

```{r tab.cap="the cars data", tab.id="cars-data"}
head(cars)
```

## Figures

```{r fig.cap="A boxplot", fig.id="boxplot"}
boxplot(1:8)
```

```{r fig.cap="What a barplot", fig.id="barplot"}
barplot(1:8)
```

## Reference

See figure \@ref(fig:boxplot) and figure \@ref(fig:barplot) and
table \@ref(tab:mtcars-data) and table \@ref(tab:iris-data) and
table \@ref(tab:cars-data)!

Solution

  • As it turns out updating from flextable 0.6.6 to flextable 0.9.2 fixes this.