Aurélien
Aurélien

Reputation: 113

r color disappear in printing

I made a markdown in html, using kable on a dataframe. I set a background color, it works on the browser, but when i want to print paper, the color disappear... I would like to do a layout too (page break, jump line), i searched, i saw some code, i tested, but nothing works...

The code for color :

kable(tableEvo,"html",
               booktabs=T,
               caption=paste("Fonds et Benchmarks respectifs au",format(ajd,"%d-%m-%Y"),sep(" "))%>%
               kable_styling("basic","condensed")%>%
               row_spec(c(2,4,6,8,10,12,14,16,18,20,22,24,26),background="#33FFFF")%>%
               column_spec(1:5,bold=TRUE)

Upvotes: 0

Views: 1088

Answers (2)

madsR
madsR

Reputation: 125

The simple solution is to put !important behind the color name in the code.

For instance if the background color chosen is red, write:

 background = "red !important"

This worked for me.

Thanks to Hao, for clarifying this for me over e-mail.

Upvotes: 0

Hao
Hao

Reputation: 7826

This is actually bootstrap's fault. It will take away all your background color when print.

See Bootstrap print CSS removes background color

I will try to open up the webpage in Safari and check "print background" on the printing page.

Upvotes: 1

Related Questions