我想让我的YAML标题信息以我的html文档为中心。
我希望其他所有内容都保持正常状态。
我可以将任何html或其他代码应用于YAML标头以实现此目的吗?
我该怎么做?
示例:
我有:
---
title: "Shiny HTML Doc"
author: "theforestecologist"
date: "Apr 14, 2017"
output: html_document
runtime: shiny
---
答案 0 :(得分:10)
以下是一些可用于完成所需内容的CSS样式。
h1.title
CSS选择器h4.author
CSS选择器h4.date
CSS选择器以下是代码:
---
title: "Shiny HTML Doc"
author: "theforestecologist"
date: "Apr 14, 2017"
output: html_document
runtime: shiny
---
<style type="text/css">
h1.title {
font-size: 38px;
color: DarkRed;
text-align: center;
}
h4.author { /* Header 4 - and the author and data headers use this too */
font-size: 18px;
font-family: "Times New Roman", Times, serif;
color: DarkRed;
text-align: center;
}
h4.date { /* Header 4 - and the author and data headers use this too */
font-size: 18px;
font-family: "Times New Roman", Times, serif;
color: DarkBlue;
text-align: center;
}
</style>
# H1 Header
Some body text
## H2 Header
More body text
```{r echo=T}
n <- 100
df <- data.frame(x=rnorm(n),y=rnorm(n))
```
这就是最终的结果: