Search code examples
r-markdownxaringan

How to move my title position with background image in Xaringan?


Hi I added background image for my title page but once I added the following in order to move my title to top and left, the background image was gone.

Is there any way to fix this issue?

titleSlideClass: [top, left]

---
title: "ECON"
subtitle: "Course Outline"
author: "Instructor"
institute: "University"
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
      titleSlideClass: [top, left]
 
---

Solution

  • You may want to create your own title slide. To do that, as per the documentation

    If you'd like to create your own title slide, disable xaringan's title slide with the seal = FALSE option of moon_reader.

    So seal xaringan's default title slide and create your own slide using rmarkdown::metadata and control the title position using class: title-slide, top, left

    ---
    title: "ECON"
    subtitle: "Course Outline"
    author: "Instructor"
    institute: "University"
    output: 
      xaringan::moon_reader:
        css: [default, metropolis, metropolis-fonts, "styles.css"]
        lib_dir: libs
        seal: false
        nature:
          highlightStyle: arta
          highlightLines: true
          countIncrementalSlides: false
          
     
    ---
    class: title-slide, top, left, inverse
    background-image: url(lights.jpg)
    background-size: cover
    
    # **`r rmarkdown::metadata$title`**
    ## **`r rmarkdown::metadata$subtitle`**
    ### `r rmarkdown::metadata$author`
    ### `r rmarkdown::metadata$institute`
    ### `r Sys.Date()`
    
    ---