RMarkdown表列名称中的Latex数学表达式 [英] Latex math expression in RMarkdown table column name
本文介绍了RMarkdown表列名称中的Latex数学表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的降价文档中显示一个表格,并将列名设置为Latex数学公式,例如$ \ dot(m)_1 $.
I want to display a table in my markdown document and set the column names to be Latex mathematical formulas such as $\dot(m)_1$.
我尝试过:
knitr::kable(my.df[, c("Time", "MassFlowRate")],
row.names = FALSE,
col.names = c("Time", "$\dot{m}_1$"))
但这是行不通的.
我不会生成PDF,但最终会生成Word文档.因此,直接对Latex表进行编码不是一种选择.
I don't generate a PDF, but a Word document in the end. So directly coding a Latex table is not an option.
推荐答案
您需要对传递给R代码的 \
进行转义,因此 \ dots
应该为 \\点
:
You need to escape \
passed into R code so \dots
should be \\dots
:
```{r}
my.df <- data.frame(Time=rnorm(10), MassFlowRate = rnorm(10))
knitr::kable(my.df[, c("Time", "MassFlowRate")],
row.names = FALSE,
col.names = c("Time", "$\\dot{m}_1$"))
```
这篇关于RMarkdown表列名称中的Latex数学表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文