5

在 xaringan 中,我想在标题幻灯片中添加背景。我已经按照一辉的指示做到了。

这行得通,除了我失去了默认字体 (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;
}
4

2 回答 2

6

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

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

在 R Markdown 书的第 7.5 节中查看更多信息。

于 2018-08-11T14:49:18.573 回答
0

我想我已经想通了。我已将字体调用添加到自定义 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中找到了这个

于 2018-08-10T19:56:35.620 回答