能否在flextable中包含$math$公式?

4

我想在一个漂亮的格式化表格中添加一些花哨的方程式。使用 flextable 可以实现吗?

library(flextable)
df <- data.frame(FancyMath= c("$A^{-1}$", "$A = pi~r^2$"))
flextable(df)

我期望使用 $ $ 符号生成数学式样的写作方式,但实际效果并非如此。谢谢!

1个回答

4

答案取决于你如何理解你的问题:

  1. 是否可以在flextables中包含$math$,即具有LaTeX语法的数学公式$math$

不,这是不可能实现的。

  1. 是否可以在flextables中包含“math”?

是的,你需要的是:

install.packages("equatags")
library(flextable)

df <- data.frame(FancyMath = c("A^{-1}", "A = pi~r^2")) # Note `$` signs are omitted
flextable(df) |>
  compose(j = "FancyMath", value = as_paragraph(as_equation(FancyMath)))

1
|>是R语言基本的管道操作符(https://towardsdatascience.com/understanding-the-native-r-pipe-98dea6d8b61b)。 - ekatko1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接