0

I was wondering if there is a simple way to do the change of font size, colour and style (bold, italic, etc.) for particular words or phrases in individual xaraingan slides within rmarkdown.

The following is my code:

---
title: "Econ"
subtitle: "Week 1"
author: "Instructor"
date: "`r Sys.Date()`"
output: 
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts]
    lib_dir: libs
    nature:
      highlightStyle: arta
      highlightLines: true
      countIncrementalSlides: false
    
---

# Is economics a science?

--
Probably not, maybe pseudo-science?.

I want to make "pseudo-science" bold, italicized, red, slightly bigger.

jck21
  • 751
  • 4
  • 16

1 Answers1

1

To style certain lines or phrases, you need to define your own content class (say .my-style) using CSS and wrap those lines or phrases with that content class (like .my-style[lines or phrases]) and define CSS rules for styles that you want to use in CSS file styles.css. Then attach that CSS file by specifying it in the YAML key css: along with other style files.

---
title: "Econ"
subtitle: "Week 1"
author: "Instructor"
date: "`r Sys.Date()`"
output: 
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts, "styles.css"]
    lib_dir: libs
    nature:
      highlightStyle: arta
      highlightLines: true
      countIncrementalSlides: false
    
---

# Is economics a science?

--
Probably not, maybe .my-style[pseudo-science]?.

styles.css

.my-style {
  font-weight: bold;
  font-style: italic;
  font-size: 1.5em;
  color: red;
}
shafee
  • 15,566
  • 3
  • 19
  • 47
  • Thank you. I am pretty new. Could you tell me where to write and store `styles.css` file and how to create `styles.css` file? – jck21 Aug 04 '22 at 18:13
  • 1
    you can create css file from Rstudio by following `File > New File > CSS file` and save it at the same place where your Rmarkdown file is saved. – shafee Aug 04 '22 at 18:43