9

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?

Shehary
  • 9,825
  • 10
  • 37
  • 69
adam.888
  • 7,336
  • 17
  • 63
  • 102

1 Answers1

6

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 ; 
}   
Yihui Xie
  • 26,509
  • 22
  • 178
  • 407
csgillespie
  • 57,032
  • 13
  • 142
  • 178
  • 1
    Thanks. For some reason this didn't work for me but then I tried: which worked fine. – adam.888 Feb 12 '15 at 17:05
  • This only works if I add the `!important` rule to the `max-width` definition as proposed in [this answer](https://stackoverflow.com/a/38373846/7196903). Using that rule [seems bad practice](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity#The_!important_exception), so is there another way? – Salim B Nov 02 '17 at 16:30
  • 5
    This also didn't work for me (nothing changed). @adam.888 could you share where/how you added "" to make it work? Thanks! – Random Certainty Dec 12 '17 at 21:21