Skip to content

flextable and knitr/markdown/docx #175

@HJAllen

Description

@HJAllen

flextable is a library for creating docx tables which adds word xml directly to the knitted document. I have been using pandoc-crossref in a Rstudio/rmarkdown/knitr/docx workflow with pandoc.table with great success. With flextable, there isn't the option to add a tag to the caption in a way similar to pandoc.table.
Questions:

  1. Has anyone developed a solution for use with pandoc-crossref?
  2. If not, might one be able to place the table in a
    tag similar to multi-figures or code blocks?

Below is a reproducible .Rmd snippet.

---
title: "flextableSnippet"
output: word_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(flextable)
```

## flextable table

```{r}
iris.t <-
  iris[1:5,] %>%
  regulartable() %>% 
  style(pr_c = officer::fp_cell(vertical.align = "bottom",
                                border.bottom = officer::fp_border(width = 2)), part = "header") %>% 
  rotate(j = names(iris)[-c(1:2)],
         rotation = "tbrl", part = "header", align = "bottom") %>% 
  height(height = max(dim_pretty(., part = "header")$widths), part = "header") %>% 
  width(width = dim_pretty(.,part = "body")$widths)%>% 
  add_footer(top = TRUE, Sepal.Length = "Sample Dates.")
iris.t
```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions