Xaringan 标题幻灯片

Xaringan Title Slide

在xaringan,我想在标题幻灯片中添加背景。 我已经按照 Yihui's 说明完成了这项工作。

这有效,除了 我松开默认字体 (Yanone Kaffeesatz)

YAML:

---
title: "My title"
subtitle: "My subtitle"
author: "Me Myself"
date: "01/01/2012"
output:
  xaringan::moon_reader:
    css: my-theme.css
    lib_dir: libs
    nature:
      ratio: '16:9'
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---


其中 my-theme.css 如下:

.title-slide {
  background-image: url(Figures/MyBackground.jpg);
  background-size: cover;
}

我想我已经明白了。我已将字体调用添加到自定义 css。所以现在我的 my-theme.css 看起来像:

.title-slide {
background-image: url(Figures/Suncor_2018_Background.jpg);
background-size: cover;
}


@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:400,700);

body { font-family: 'Droid Serif', 'Palatino Linotype', 'Book Antiqua', Palatino, 'Microsoft YaHei', 'Songti SC', serif; }
h1, h2, h3 {
  font-family: 'Yanone Kaffeesatz';
  font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Source Code Pro', 'Lucida Console', Monaco, monospace; }

我在 default-fonts.css 中找到了这个 ...\library\xaringan\rmarkdown\templates\xaringan\resources

我不建议您将 default-fonts.css 添加到您的 my-theme.css。如果你想要默认字体,你可以使用

output:
  xaringan::moon_reader:
    css: [default, default-fonts, my-theme.css]

Section 7.5 的 R Markdown 书中查看更多信息。