How to print html pages with colors?

I think this is related by the fact that default document is using Bootstrap 3 and this framework has some specific CSS rules for printing. This is a limitation (issues) of Bootstrap 3.

Please see the discussion in

Setting !important is a way to make the CSS rules the most important, so it will override any other and so it will apply even during Printing.

As I explained in the issue linked above, you could use newer version of bootstap to avoid this issue.

---
title: "Untitled"
output: 
  html_document:
    theme:
      version: 4
---

it should be better.

1 Like