Increase width of entire HTML Rmarkdown output

NateSully picture NateSully · Jan 20, 2016 · Viewed 15.9k times · Source

I am looking to increase the overall width of my HTML Rmarkdown output.

When producing PDF documents from Rmarkdowns there is an option to set the margin in the YAML section of the Rmd (ex. geometry: margin=.5in).

I am looking for something similar for HTML docs. The following link is a good example of my issue: https://rstudio.github.io/DT/extensions.html

As you can see on that html webpage, there is a lot of white space to the left and right of the datatables. Is there a way to reduce this margin space and thus increase the width of the datatables?

Thanks

Answer

Rasmus Larsen picture Rasmus Larsen · Oct 4, 2017

Put this at the top (but below the YAML) of your rmarkdown document:

<style type="text/css">
.main-container {
  max-width: 1800px;
  margin-left: auto;
  margin-right: auto;
}
</style>

Don't put it in a chunk but as plain text. It should set the max-width of the content area to 1800px.