Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the strip color on kableExtra

The color of the strips are very lite on Kable on Pdf output. So is there a way to change the color on kable_styling(latex_options = "striped")?

like image 738
S.Perera Avatar asked Aug 16 '17 16:08

S.Perera


2 Answers

The author of the kableExtrapackage @hao was kind to add this option. The answer can be found on change the strip color on kableExtra

like image 157
S.Perera Avatar answered Nov 14 '22 19:11

S.Perera


Cobbling together the link provided by @S.Perera above (where @hao states no functionality for hex codes yet), deciding I didn't like the available LaTeX color codes found here (code for modifying just below that), an attempt to change stripe color described here, and my own desire to fine-tune with hex codes, I came up with the following:

In the YAML:

---
output:
  pdf_document:
    latex_engine: xelatex
header-includes: \definecolor{ltgray}{HTML}{D3D3D3}
---

ltgray is the new name for the color, HTML is the model (you can also do RGB or CMYK), and D3D3D3 is the hex code for the color I want. Assuming my dataframe for the table is called df:

kable(df, format = "latex", booktabs=TRUE) %>%
    kable_styling(latex_options = "striped", stripe_color="ltgray")
like image 44
bcarothers Avatar answered Nov 14 '22 20:11

bcarothers