[R] Controlling font size on code chunk outputs using Knitr

Yihui Xie xie at yihui.name
Mon Feb 3 19:24:13 CET 2014


R.css is irrelevant. The default CSS has already been mentioned in the
documentation: https://support.rstudio.com/hc/en-us/articles/200552186-Customizing-Markdown-Rendering

You should not define the rstudio.markdownToHTML option _inside_ the
Rmd document: do it in the current R console, or in .Rprofile --
again, please read the documentation carefully.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name


On Fri, Jan 31, 2014 at 6:18 PM, Jeff Johnson <mrjefftoyou at gmail.com> wrote:
> Yihui/Jeff,
>
> I'm trying to determine where the default CSS file is located as I don't see
> this in any of the documentation. I can definitely find a markdwon.css file
> in  C:\Program Files\RStudio\resources
>
> I also see an R.css file in that directory.
>
> I also have R.css in C:\Users\jeffjohn\Dropbox\R\Rlibs\rstudio\html which is
> where I have all of my packages installed. Would you know how I can
> determine what CSS file a given .Rmd file is referencing?
>
> However, I've tried making a simple change to each of them (first backing
> them up of course) by changing the h1 to small instead of x-large and saving
> the doc, but when I knit the document it does not change anything.
>
> Any guidance you can provide would be extremely helpful. Again, I'm using
> R-Studio on Windows.
>
>
> On Thu, Jan 30, 2014 at 3:54 PM, Jeff Johnson <mrjefftoyou at gmail.com> wrote:
>>
>> Thanks Yihui and Jeff.
>>
>> I've retrieved the default CSS file and made a tweak to it (changing a
>> header 1 size just to test it) and saved it to the same local directory as
>> my .Rmd file using the name 'mymarkdown.css' for testing.
>>
>> I've added:
>> options(rstudio.markdownToHTML =
>>   function(inputFile, outputFile) {
>>     require(markdown)
>>     markdownToHTML(inputFile, outputFile, stylesheet='mymarkdown.css')
>>   }
>> )
>>
>> to the top of my testfile.Rmd file so that my file now looks like:
>>
>> options(rstudio.markdownToHTML =
>>   function(inputFile, outputFile) {
>>     require(markdown)
>>     markdownToHTML(inputFile, outputFile, stylesheet='mymarkdown.css')
>>   }
>> )
>>
>> Title
>> ========================================================
>>
>> This is an R Markdown document. Markdown is a simple formatting syntax for
>> authoring web pages (click the **Help** toolbar button for more details on
>> using R Markdown).
>>
>> When you click the **Knit HTML** button a web page will be generated that
>> includes both content as well as the output of any embedded R code chunks
>> within the document. You can embed an R code chunk like this:
>>
>> ```{r}
>> summary(cars)
>> ```
>>
>> But when I knit it, it just writes the "options" chunk at the top of my
>> document. Am I supposed to add something else to get the .rmd file to
>> reference the css?
>>
>> I'm quite new to programming and R (as if you couldn't tell!), so not sure
>> what additional steps I need to add.
>>
>> Thanks much.
>> Jeff




More information about the R-help mailing list