如何在rmarkdown的kable表中更改单元格的字体(粗体/斜体)? [英] How to change fontface (bold/italics) for a cell in a kable table in rmarkdown?

查看:179
本文介绍了如何在rmarkdown的kable表中更改单元格的字体(粗体/斜体)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在rmarkdown中格式化表格中的单个单元格?我正在使用kable生成表,如下所示:

Is there a way to format a single cell in a table in rmarkdown? I am using kable to generate a table as follows:

library(knitr)
kable(data.frame(c('a','b','c'),c(1,2,3)))

我希望在最后一行加粗"c",并在表格末尾添加一条水平线.有指针吗?

I wish to bold "c" in the last row and also add a horizontal line at the end of the table. Any pointers?

推荐答案

pander突出显示单元格,行或列很容易

Highlighting cells, rows or columns with pander is pretty straightforward:

> df <- data.frame(c('a','b','c'),c(1,2,3))
> emphasize.strong.cells(which(df == 3, arr.ind = TRUE))
> pander(df)

-------------------------------
 c..a....b....c..   c.1..2..3. 
------------------ ------------
        a               1      

        b               2      

        c             **3**    
-------------------------------

但是在表格中添加水平线超出了 markdown表格规范的范围

But adding horizontal line to the table is out of the scope of markdown table specifications.

这篇关于如何在rmarkdown的kable表中更改单元格的字体(粗体/斜体)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆