簡體   English   中英

Rmarkdown字體大小和標題

[英]Rmarkdown font size and header

我最近打開了一個標准的Rmd文件而沒有編輯任何內容。 默認文件如下所示:

Untitled.rmd

---
title: "myfile"
author: "Me"
date: "May 25, 2015"
output: html_document
fontsize: 12pt
---

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}
summary(cars)
```

You can also embed plots, for example:

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

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

我想創建一個與上述文件對應的html文件,因此在單獨的R腳本中我執行了以下操作:

knit('Untitled.Rmd', 'doc.md')
markdownToHTML('doc.md', 'testing.html',header = TRUE)

由於某種原因,字體大小不起作用,我希望的標題信息不會出現在我的testing.html中。 任何人都知道為什么會這樣嗎?

這是我用來控制R-markdown文件中的字體大小和顏色。 它基本上覆蓋了CSS樣式表,而無需創建新文件。 該示例更改標題和標題的大小,以及內聯文本和R代碼文本,並設置一些顏色。

在我的情況下,我需要將更多信息打包到具有指定頁數的文檔中,因此我將所有內容都縮小了。

---
title: "This is a title"
date: 25 May 2015
output:
html_document:
theme: cerulean
---

<style type="text/css">

body{ /* Normal  */
      font-size: 12px;
  }
td {  /* Table  */
  font-size: 8px;
}
h1.title {
  font-size: 38px;
  color: DarkRed;
}
h1 { /* Header 1 */
  font-size: 28px;
  color: DarkBlue;
}
h2 { /* Header 2 */
    font-size: 22px;
  color: DarkBlue;
}
h3 { /* Header 3 */
  font-size: 18px;
  font-family: "Times New Roman", Times, serif;
  color: DarkBlue;
}
code.r{ /* Code block */
    font-size: 12px;
}
pre { /* Code block - determines code spacing between lines */
    font-size: 14px;
}
</style>


# H1 Header

Some body text

## H2 Header

More body text

### H3 Header

blah blah blah

```{r echo=T}
n <- 100
df <- data.frame(x=rnorm(n),y=rnorm(n))
```

### Another H3

更新:

添加了更多樣式,注釋和一些顏色,使這個答案更有用。 還有一個屏幕截圖:

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM