Rmarkdown字体大小和标题 [英] Rmarkdown font size and header
问题描述
我最近打开了一个标准的Rmd文件,没有任何编辑。默认文件如下所示:
I recently opened a standard Rmd file without editing anything. The default file looks like this:
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脚本中
I wanted to create an html file corresponding to the above file so in a separate R script I did the following:
knit('Untitled.Rmd', 'doc.md')
markdownToHTML('doc.md', 'testing.html',header = TRUE)
出于某种原因,字体大小工作和我希望的标题信息不会出现在我的testing.html。任何人都知道为什么会发生这种情况?
For some reason the font size doesn't work and the header information that I was hoping for doesn't appear in my testing.html. Anyone know why this is happening?
推荐答案
这是我用来控制字体大小和颜色的R-markdown文件。它基本上覆盖CSS样式表,而不必创建一个新文件。该示例更改标题和标题的大小,以及内联文本和R代码文本,并设置一些颜色。
This is what I used to control font size and color in an R-markdown file. It basically overrides the CSS style sheets without having to create a new file. The example changes the sizes of the headers and titles, as well as the inline text and the R-code text, and sets some colors as well.
在我的case I需要将更多信息打包到具有指定页数的文档中,以便我将所有内容缩小。
In my case I needed to pack more information into a document that had a specified number of pages so I made everything smaller.
---
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 { /* Header 1 */
font-size: 28px;
color: DarkBlue;
}
h2 { /* Header 2 */
font-size: 22px;
color: DarkBlue;
}
h3 { /* Header 3 */
font-size: 18px;
color: DarkBlue;
}
code.r{ /* Code block */
font-size: 10px;
}
pre { /* Code block */
font-size: 10px
}
</style>
更新:
,注释和一点颜色,使这个答案更有用
Update:
Added more more styles, comments, and a bit of color to make this answer more useful
这篇关于Rmarkdown字体大小和标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!