3

因此,有一些关于 SO 的问题,但似乎没有一个问题可以解决这个特定问题。

我正在寻找使用自定义 CSS 模板自定义从 RStudio 创建的 RMarkdown/Slidy 演示文稿。

  • RStudio 已经允许使用内置的 Bootswatch 主题进行最少的定制,因此可以访问output: slidy presentation / theme: readable
  • 还有其他未内置的 Bootswatch 主题;特别是我可能想使用Cyborgor Slate,它有一个漂亮的深色背景(而不是白色)

以下是使用自定义文件覆盖 Slidy CSS 的直观解决方案:

```{css}

<link href="bootstrap-slate.css" rel="stylesheet">

```

但是,它失败了:

pandoc.exe: Could not fetch .\../fonts/glyphicons-halflings-regular.eot
.\../fonts/glyphicons-halflings-regular.eot: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
In addition: Warning message:
running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS segmentations.utf8.md --to slidy --from 
markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --
output segmentations.html --smart --email-obfuscation none --self-contained --template "C:\Users\ME\Documents\R\R-3.3.3\library\rmarkdown\rmd\slidy\default.html" --include-in-header 
"C:\Users\ME\AppData\Local\Temp\RtmpGYLCFf\rmarkdown-str378022cf50b0.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments' had status 67 
Execution halted

欢迎大家提出意见。请注意,文档 rMarkdown 文档中的解决方案不起作用。解决方案复制到这里以供参考:

---
output:
  slidy_presentation:
    css: styles.css         ## 
---

Error in yaml::yaml.load(string, ...) : 
  Scanner error: mapping values are not allowed in this context at line 5, column 21
Calls: <Anonymous> ... parse_yaml_front_matter -> yaml_load_utf8 -> <Anonymous> -> .Call
Execution halted
4

2 回答 2

1

问题后很长时间,但为了后代:

我发现这段代码主要使用您自己的示例来工作。使用本地 css 文件。

降价:

---
title: "CSS and Slidy"
author: Your name here
date: 2018-05-31
output: 
  slidy_presentation
---

Outline
======================================================

<link href="foo.css" rel="stylesheet">

- Hello
- World

相关的css文件:

body {
    color: blue;
}

h1 {
    color: green;
}

输出:

在此处输入图像描述

注意:我发现RMarkdown Slidy Presentations 中的自定义 CSS不起作用:

---
output:
  slidy_presentation:
    css: foo.css          
---
于 2018-05-31T16:30:50.253 回答
0

通过发展我对 Bootstrap 的理解,我设法回答了我自己的问题

我需要使用整个 Bootstrap 目录,而不仅仅是我的 WD 中的 Bootswatch 主题 css 文件。然后,要使用“Slate”或其他任何一个,需要用新主题替换默认的 Bootstrap.css。

这篇文章(如何在 bootstrap 3 中包含字形图标) 有一个完美描述它的最佳答案:

于 2017-06-07T02:12:25.863 回答