Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 412
badmax Avatar asked Jul 07 '14 04:07

badmax


Video Answer


2 Answers

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.

like image 35
Kyle Avatar answered Sep 28 '22 20:09

Kyle


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
---
like image 156
Jonathan Avatar answered Sep 28 '22 20:09

Jonathan