rr-markdownbookdownkableflextable

Producing table for .docx output with superscripts in footnote rmarkdown


I like using flextable for tables when knitting to word. In this table I want to put superscripts in the footnote. For pdf outputs I use kableExtra and put the relevant text for the foot note as bookdown style reference (also helpful if I want to include a citation to bibliography in the footnote). I've tried something similar with flextable but doesn't work.

Code chunk attempts:

{r tab1}
flextable::flextable(iris)%>%
add_footer_lines("My footnotes with ^supercript^ text")

This doesn't work so tried

(ref:footnote) My footnotes with ^supercript^ text with reference @paper2023
{r tab1}
flextable::flextable(iris)%>%
add_footer_lines('ref:footnote')

How can I produce a table in a word document, with superscripts and citations in a footnote? Happy to consider other packages than flextable


Solution

  • There is no support for pandoc citations (flextable does not use pandoc).

    ---
    title: "Untitled"
    output: word_document
    ---
    
    ```{r setup, include=FALSE}
    knitr::opts_chunk$set(echo = TRUE)
    ```
    
    ```{r}
    library(flextable)
    ft <- qflextable(head(iris)) |> 
      add_footer_lines(
        as_paragraph(
          "My footnotes with ",
          as_sup("supercript"),
          " text"
        )
    )
    ft
    ```
    
    

    enter image description here