badmax
badmax

Reputation: 645

Changing the maximum width of R markdown documents

When I create an R Markdown file and knit HTML, the following is present:

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

I would like to change the max-width attribute. How would I do that?

Thanks.

Upvotes: 18

Views: 14353

Answers (2)

Kyle
Kyle

Reputation: 411

If you are only making HTML output you can put

<style>
    body .main-container {
        max-width: 500px;
    }
</style>

at the beginning of the .Rmd file I put mine after the front matter.

Upvotes: 15

Jonathan
Jonathan

Reputation: 8812

There's no way to change that number specifically, but you can override it. Create your own style.css file in the same directory as your document, and give it some content:

body .main-container {
max-width: 500px;
}

Then reference that CSS file in your YAML front matter:

---
...
output:
  html_document:
    css: style.css
---

Upvotes: 32

Related Questions