Search code examples
rflextable

Add mathematical notation (dot above letter) to flextable


I would like to add mathematical notation: V ̇ O2peak to my flextable.

This is my mwe and attempt:

df = data.frame(item = c("vo2", "age"),
                mean = c(30,40))
df

flextable(df)%>%
  mk_par(i=1, j=1, as_paragraph(" $\dot{V}$O", as_sub(2peak) ))
# also attempted

flextable(df)%>%
  mk_par(i=1, j=1, as_paragraph(as_equation($\dot{V}$O), as_sub(2peak) ))


Solution

  • You need to use as_equation() that expects MathJax syntax:

    library(flextable)
    df <- data.frame(
      item = c("vo2", "age"),
      mean = c(30, 40)
    )
    
    flextable(df) |>
      mk_par(i = 1, j = 1, as_paragraph(
        as_equation("\\dot{V}0_{2peak}")
      ))
    

    enter image description here