0

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)
Aurélien
  • 103
  • 3
  • 12
  • Can you provide a sample of `tableEvo` so this problem is reproducible? Also, does it matter whether you print HTML directly to paper, or would it be OK to render a PDF or Word doc that you then print? – mysteRious Apr 04 '18 at 12:58
  • 1
    Sounds more like a problem with the printer than a problem with programming. Have you tried a different colour? –  Apr 04 '18 at 13:21

2 Answers2

1

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.

Hao
  • 7,476
  • 1
  • 38
  • 59
0

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.

madsR
  • 95
  • 6