Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Caption font color with kable

Using kable() to render a simple table yields what seems to be the default pale font color for the table caption in the resulting html file. Is there a way to control the table (or figure) caption font color, size, etc?

    ---
    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")
    ```
like image 953
Ani Avatar asked Dec 24 '15 01:12

Ani


People also ask

How do I color text in R markdown?

The Markdown syntax has no built-in method for changing text colors. We can use HTML and LaTeX syntax to change the formatting of words: For HTML, we can wrap the text in the <span> tag and set color with CSS, e.g., <span style="color: red;">text</span> . For PDF, we can use the LaTeX command \textcolor{}{} .

How do you change the color of a caption in HTML?

Coloring text in <caption> tag:CSS color property describes the color of the text content and text decorations. CSS background-color property sets the background color of an element.


1 Answers

Aha! Customizing the CSS stylesheet does the trick.

    caption {
      color: red;
      font-weight: bold;
      font-size: 1.0em;
    } 
like image 59
Ani Avatar answered Sep 30 '22 04:09

Ani