如何在rmarkdown中编辑bootstrap主题?

时间:2017-05-25 19:52:42

标签: css r rstudio r-markdown

我目前正在使用rmarkdown中的 cosmo 主题。如果我想更改导航菜单的颜色,或者更具体地说是菜单突出显示,我应该编辑哪个文件?

1 个答案:

答案 0 :(得分:6)

如果您真的想要更改cosmos CSS,可以在此处找到它:[path to libraries]/rmarkdown/rmd/h/bootstrap-3.3.5/css/cosmo.min.css但是如果我只需要更改一件事,我通常只需将CSS放入markdown文档中,如下例所示。

您还可以附加自己的CSS,如下所示:http://rmarkdown.rstudio.com/html_document_format.html#custom_css

---
title: "Untitled"
author: "Ian Wesley"
date: "May 25, 2017"
output: 
  html_document:
    theme: cosmo

---

<style>
  h2{
    font-size: 50px !important;
    color: crimson !important
  }
</style>

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```