I don't think this is an R issue, it's a HTML tables issue // browser issue.
There are some hacks using background image (not R specific). BUT before you do any of this... Consider if colour is your answer! 8% of males are colour blind, so your table isn't as accessible as you may think it is. That's before you get to people who print in B&W etc On Sat, 17 Dec 2022, 00:21 Matthew Pirritano, <mpirrit...@lacare.org> wrote: > Hey, all! > > I've got a report that uses datatable from DT to create an rmarkdown html > that looks great as an html but when I try to print it, to a printer, or to > a pdf the colors I've assigned to cells are not displaying. I'm using > chrome and I've clicked on the Background graphics button there, but that > doesn't help print the colors. I have tried to run the datatable section of > the code using results = 'asis' and eliminating results = 'asis'. Neither > seems to help with the > > My css style at the top of the rmarkdown is > > <style type="text/css"> > .main-container { > max-width: 1500px; > margin-left: auto; > margin-right: auto; > table.display td { white-space: wrap; } > > } > td{ > -webkit-print-color-adjust:exact !important; > print-color-adjust:exact !important; > } > </style> > > I added the webkit bit based on what I've found online. Maybe I have > something set up incorrectly there? Any ideas or thoughts on how to get > this to print the background colors? > > Thanks > matt > > > > > ________________________________ > > This communication is intended for the use of the individual or entity to > which it is addressed and may contain information that is privileged, > confidential or otherwise exempt from disclosure under applicable law. If > you are not the intended recipient, you are hereby notified that any > dissemination, distribution or copying of this communication is strictly > prohibited. If you have received this communication in error, please notify > the sender and delete any copies. Thank you. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.