2017-08-24 313 views
2

我是使用R程序包revealjs創建Reveal JS和R Markdown演示文稿的新手,並且我一直在關注如何減少標題字體大小。在Reveal JS R Markdown中更改標題字體大小

我看到了這樣的回答: Changing the font size of figure captions in RMarkdown HTML output

而且還檢查了: http://rmarkdown.rstudio.com/revealjs_presentation_format.html#custom_css

但不幸的是我似乎失去了一些東西,它似乎並沒有工作! 任何幫助任何人都可以提供將不勝感激:)

這是我的[R降價:

--- 
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) 

``` 

回答

1

所以,事實證明,我需要有一個額外的CSS文件。 我在我的工作目錄中保存了一個名爲custom_css.css的css文件。 這是CSS代碼:

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

然後,在我的RMarkdown文件,編寫的代碼是:

--- 
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) 

```