Choppy123
Choppy123

Reputation: 101

Change caption font size in Reveal JS R Markdown

I'm new to creating presentations with Reveal JS and R Markdown using the R package revealjs, and I'm stuck on how to reduce the caption font size.

I saw this answer: Changing the font size of figure captions in RMarkdown HTML output

And also checked out: http://rmarkdown.rstudio.com/revealjs_presentation_format.html#custom_css

But unfortunately I seem to be missing something and it doesn't seem to work! Any help anyone can provide would be greatly appreciated :)

This is my R Markdown:

    ---
title: "Cars"
author: "Me"
date: "24 August 2017"
output:
  revealjs::revealjs_presentation:
    fig_caption: yes

---

<style>

.reveal section p.caption {
  font-size: 0.2em;
}

</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r,echo = FALSE, warning = FALSE,message=FALSE, fig.cap= "Cars"}

library(ggplot2)
data(mtcars)
g <- ggplot(mpg, aes(class))
g <- g + geom_bar()

print(g)

```

Upvotes: 2

Views: 1659

Answers (1)

Choppy123
Choppy123

Reputation: 101

So it turns out that I needed to have an additional css file. I saved a css file called custom_css.css in my working directory. This was the css code:

.reveal section figcaption {
  font-size: 0.3em;
}

Then, in my RMarkdown file, the code written was:

---
title: "Cars"
author: "Me"
date: "24 August 2017"
output:
  revealjs::revealjs_presentation:
    css: custom_css.css
    fig_caption: yes


---


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

```{r,echo = FALSE, warning = FALSE,message=FALSE, fig.cap= "Cars"}

library(ggplot2)
data(mtcars)
g <- ggplot(mpg, aes(class))
g <- g + geom_bar()

print(g)

```

Upvotes: 3

Related Questions