rmarkdown 文件中的 Kable 标题以粗体显示在 HTML 中

问题描述:

我想用粗体显示我的表格标题,但似乎找不到相应的选项.

I want to make my table caption in bold but can't seem to find the option for it.

我的代码是(在 rmarkdown 文档中):

My code is (in a rmarkdown document):

kable(head(iris), caption = 'I want this in Bold') %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive")) 

输出为:

这个面向 Markdown 的解决方案适合你吗?

Does this markdown-oriented solution work for you?

```{r, results='asis'}
kable(head(iris), caption = '**I want this in Bold**') %>% 
  kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed","responsive"))
```

对于 html-output 这应该可以工作:


for html-output this should work:

```{r, results='asis'}
kable(head(iris), caption = '<b>I want this in Bold</b>', format = 'html') %>% 
  kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed","responsive"))
```

对于 pdf-输出,这应该可以工作:


for pdf-output this should work:

```{r, results='asis'}
kable(head(iris), caption = '\\textbf{I want this in Bold}', format = 'latex') %>% 
  kableExtra::kable_styling(bootstrap_options = c("striped", "hover", "condensed","responsive"))
```