Change Font Sizes with Style Sheets for Rstudio Presentation

R Markdown - changing font size and font type in html output

I think fontsize: command in YAML only works for LaTeX / pdf. Apart, in standard latex classes (article, book, and report) only three font sizes are accepted (10pt, 11pt, and 12pt).

Regarding appearance (different font types and colors), you can specify a theme:. See Appearance and Style.

I guess, what you are looking for is your own css. Make a file called style.css, save it in the same folder as your .Rmd and include it in the YAML header:

---
output:
html_document:
css: style.css
---

In the css-file you define your font-type and size:

/* Whole document: */
body{
font-family: Helvetica;
font-size: 16pt;
}
/* Headers */
h1,h2,h3,h4,h5,h6{
font-size: 24pt;
}

How to change sub-bullet points font size in Rpres?

I just fought this battle and FML it's painful.

I ended up doing this in my css:

/* body text, ordered and unordered list styles */
.reveal ul,
.reveal ol,
.reveal p{
font-size: 180%;
line-height: 110%;
list-style-type: disc;
}

/* slide titles */
.reveal h3 {
font-size: 200%;
}
/* heading for slides with two hashes ## */
.reveal .slides section .slideContent h2 {
font-size: 40px;
font-weight: bold;
color: green;
}

Notice that I have the list bits and p all lumped together. I want them always to change at the same time so I assign them all at once.

Rmarkdown font size and header

This is what I used to control font size and color in an R-markdown file. It basically overrides the CSS style sheets without having to create a new file. The example changes the sizes of the headers and titles, as well as the inline text and the R-code text, and sets some colors as well.

In my case I needed to pack more information into a document that had a specified number of pages so I made everything smaller.

---
title: "This is a title"
date: 25 May 2015
output:
html_document:
theme: cerulean
---

<style type="text/css">

body{ /* Normal */
font-size: 12px;
}
td { /* Table */
font-size: 8px;
}
h1.title {
font-size: 38px;
color: DarkRed;
}
h1 { /* Header 1 */
font-size: 28px;
color: DarkBlue;
}
h2 { /* Header 2 */
font-size: 22px;
color: DarkBlue;
}
h3 { /* Header 3 */
font-size: 18px;
font-family: "Times New Roman", Times, serif;
color: DarkBlue;
}
code.r{ /* Code block */
font-size: 12px;
}
pre { /* Code block - determines code spacing between lines */
font-size: 14px;
}
</style>

# H1 Header

Some body text

## H2 Header

More body text

### H3 Header

blah blah blah

```{r echo=T}
n <- 100
df <- data.frame(x=rnorm(n),y=rnorm(n))
```

### Another H3

Update:

Added more more styles, comments, and a bit of color to make this answer more useful. And a screen shot:

Sample Image

Markdown: Change default font size of code chunks in ioslides

You can change the default font size document wide using

<style>
pre {
font-size: 20px;
}
</style>

which you can put right underneath your YAML header or in a seperate stylesheet (CSS file) that you can include in your YAML.

You may want to change the settings for padding and margin as well in order to prettify chunk layout.

Modify single chunks

It is possible to add a class to the code chunks you want to modify (if not all of them). Check out the answer here: stackoverflow.com/questions/37944197/

Code chunk font size in Rmarkdown with knitr and latex

Picking up the idea to alter a knitr hook we can do the following:

def.chunk.hook  <- knitr::knit_hooks$get("chunk")
knitr::knit_hooks$set(chunk = function(x, options) {
x <- def.chunk.hook(x, options)
ifelse(options$size != "normalsize", paste0("\n \\", options$size,"\n\n", x, "\n\n \\normalsize"), x)
})

This snippet modifies the default chunk hook. It simply checks if the chunk option size is not equal to its default (normalsize) and if so, prepends the value of options$size to the output of the code chunk (including the source!) and appends \\normalsize in order to switch back.

So if you would add size="tiny" to a chunk, then all the output generated by this chunk will be printed that way.

All you have to do is to include this snippet at the beginning of your document.

RStudio Shiny renderDataTable font size

You can put dataTableOutput("tableName") inside of div()and change the font using the style parameter. style takes CSS arguments.

For example, if have this...

dataTableOutput("tableName")

you can change it like this...

div(dataTableOutput("tableName"), style = "font-size:80%")

to make the font size 20% smaller.



Related Topics



Leave a reply



Submit