adam.888 adam.888 - 4 months ago 42
CSS Question

R knitr markown: Setting HTML page width

I am using

knitr
to create a HTML webpage. The default setting seems to be 800px but I need a larger page size of 1100px

body {
max-width: 800px;
margin: auto;
padding: 1em;
line-height: 20px ;
}


I have tried:

library("markdown")
library("knitr")
knit2html("test.Rmd",options = c(width=1100))


But this still gives me the smaller page size of 800px

How can I set the code for the HTML page width?

Answer

Add a css element to your document, e.g.

---
title: "test"

output:
  html_document:
    css: "test.css"
---

and then put your new css information in that file, e.g.

body {
  max-width: 1100px;
  margin: auto;
 padding: 1em;
 line-height: 20px ; 
}   
Comments