标题字体颜色与kable

时间:2015-12-24 01:32:47

标签: css r knitr r-markdown

使用kable()渲染一个简单的表会产生似乎是生成的html文件中表格标题的默认淡色字体颜色。有没有办法控制表(或图)标题字体的颜色,大小等?

    ---
    title: "test"
    output: 
    html_document: 
    theme: cosmo
    ---

    ```{r}
    library(knitr)
    tab.1 = table(mtcars$cyl, mtcars$vs)
    kable(tab.1, caption="Table 1: Caption Font Color")
    ```

3 个答案:

答案 0 :(得分:5)

啊哈!自定义CSS样式表可以解决问题。

var menuItems = $(".nav a");
$(".nav a").on('click', function(event) {
    event.preventDefault();
    menuItems.parent().removeClass('active');
    $(this).parent().addClass('active');
});

答案 1 :(得分:2)

添加到Ani的答案:如果您不想单独编写CSS样式表,则可以在YAML之后仅添加另一个块:

```{r results="asis"}
cat("
<style>
caption {
      color: red;
      font-weight: bold;
      font-size: 1.0em;
    }
</style>
")
```

答案 2 :(得分:1)

现在,您可以绕过R直接使用namespace OpenEMR\Repositories; use Doctrine\ORM\EntityRepository; use OpenEMR\Entities\FormEncounter; use Symfony\Component\Config\Definition\Exception\Exception; class FormEncounterRepository extends EntityRepository { /** * @param FormEncounter * @param $message * @return $response */ public function update($message) { $response = false; try { //Since it is already an object ready for storing. //Doctrine can figure out from here to replace into database entry. //I learned that persist and flush only work in the repository and not in the controller. $result = $this->_em->persist($message); $this->_em->flush(); $response = true; } catch (Exception $e) { return 'An Error occured during save: ' .$e->getMessage(); } return $response; } } 代码块。添加css使其不会成为输出的一部分。

echo = FALSE