Changing the maximum width of R markdown documents

css, knitr, r, r-markdown

Solution

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
---

Problem

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.

Original source

Related problems