Addendum to yesterday’s post on custom CSS and R Markdown


Updates from RStudio support:
(1) “Thanks for reporting and I was able to reproduce this as well. I’ve filed a bug and we’ll take a look.”
(2) Taking a further look, this is actually a bug in the Markdown package and we’ve asked the maintainer (Jeffrey Horner) to look into it.

As juejung points out in a comment on my previous post, applying custom CSS to R Markdown by sourcing the custom rendering function breaks the rendering of inline equations.

I’ve opened an issue with RStudio support and will update here with their response. In the meantime, one solution to this problem is:

  1. Do not create the files custom.css or style.R, as described yesterday
  2. Instead, just put the custom CSS at the top of your R Markdown file using style tags, as shown below
<style type="text/css">
table {
   max-width: 95%;
   border: 1px solid #ccc;
}

th {
  background-color: #000000;
  color: #ffffff;
}

td {
  background-color: #dcdcdc;
}
</style>

2 thoughts on “Addendum to yesterday’s post on custom CSS and R Markdown

  1. Jason Becker (@jasonpbecker)

    I’ve noticed something strange when using RStudio and R Markdown. For some reason, it keeps adding into the leaving me with a ToC that opens a new tab every time someone clicks. Because I’m looking to produce 75 reports in bulk, going in and editing to is not really an option.

    Do you have any inkling on where this property is set on the path from Rmd -> HTML?

    1. nsaunders Post author

      I think something is missing from your question between “adding into the” and “leaving me.” However, can’t really help you with specific issues; suggest you try asking at RStudio support or StackExchange.

Comments are closed.