1

I would like to change the color of the default table produced by pandoc in Rmarkdown. The default is blue. How can change it?

Reprex:

---
title: "reprex"
author: ""
date: ""
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## My Table

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | $1.34         | - built-in wrapper |
|               |               | - bright color     |
+---------------+---------------+--------------------+
| Oranges       | $2.10         | - cures scurvy     |
|               |               | - tasty            |
+---------------+---------------+--------------------+

My Table

tarleb
  • 19,863
  • 4
  • 51
  • 80
tall_table
  • 311
  • 3
  • 11

1 Answers1

1

The colors are controlled by CSS files. You can override the table header style by adding this in after your header block. I set the header background color to a green gradient below (#00FF00, #197419). Customize the colors by replacing those hex colors with your own values.

<style>
table.rmdtable th {
color: white;
font-size: 18px;
background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(40%, #00FF00), color-stop(80%, #197419)) no-repeat;
background: -webkit-linear-gradient(top, #00FF00 40%, #197419 80%) no-repeat;
background: -moz-linear-gradient(top, #00FF00 40%, #197419 80%) no-repeat;
background: -o-linear-gradient(top, #00FF00 40%, #197419 80%) no-repeat;
background: linear-gradient(top, #00FF00 40%, #197419 80%) no-repeat;
}
</style>
da11an
  • 701
  • 4
  • 8
  • Thanks. I added the following to a CSS and it worked. I was missing the `!important` needed to override default pandoc settings: `th { background: #041E42 !important; border-color: #EDE7DD !important; }` – tall_table Dec 11 '20 at 18:49