simoncolumbus
simoncolumbus

Reputation: 566

xaringan: kableExtra::kable_styling() and wider tables

I am using xaringan to create an html presentation, which includes some tables generated using kable(). Unfortunately, these tables are quite narrow, so I'd like to use the full_width option in kable_styling. Moreover, I'd like to turn off the striped design. An example:

library(kableExtra)

head(iris) %>% 
knitr::kable('html') %>%
kableExtra::kable_styling(full_width = TRUE, bootstrap_options = "basic")

However, it looks like the kable_styling() options are ignored by xaringan. Is it possible to make these happen, or otherwise to modify the style of kable tables when using xaringan?

Upvotes: 7

Views: 1670

Answers (1)

Fei YE
Fei YE

Reputation: 431

Try to add the following code before your kable table.

```{css, echo=F}
    /* Table width = 100% max-width */

    .remark-slide table{
        width: 100%;
    }

    /* Change the background color to white for shaded rows (even rows) */

    .remark-slide thead, .remark-slide tr:nth-child(2n) {
        background-color: white;
    }
```

If you would like to make a change to only one table, you may need to put the table in a container and modify the above code.

Let me know if it works.

Upvotes: 8

Related Questions