如何将我的YAML标题置于R markdown html文档中? [英] How do I center my YAML heading in an R markdown html document?
本文介绍了如何将我的YAML标题置于R markdown html文档中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望所有其他东西都保持在正常状态。
$我想让我的YAML头信息集中在我的html文档中。 b $ b
我可以将任何html或其他代码应用到YAML头文件中吗?
我该怎么做?
例如:
我有:
<$
作者:theforestecologist
日期:2017年4月14日
输出:html_document
runtime:shiny
---
解决方案
是一些CSS样式,你可以用它来完成你所需要的。
- 标记文档标题使用
h1.title
CSS选择器 - 降价凭证作者字段使用
h4.author
CSS选择器 - 降价凭证datea字段使用
h4.date
CSS选择器
以下是代码:
---
标题:Shiny HTML Doc
作者:theforestecologist
日期: 2017年4月14日
输出:html_document
运行时:闪亮
---
< style type =text / css>
h1.title {
font-size:38px;
color:DarkRed;
text-align:center;
}
h4author {/ * Header 4 - 作者和数据标题也使用它* /
font-size:18px;
font-family:Times New Roman,Times,serif;
color:DarkRed;
text-align:center;
}
h4.date {/ * Header 4 - 作者和数据标题也使用它* /
font-size:18px;
font-family:Times New Roman,Times,serif;
颜色:DarkBlue;
text-align:center;
}
< / style>
#H1标题
一些正文文本
## H2标题
更多正文文本
```{r echo = T}
n < - 100
df < - data.frame(x = rnorm(n) ,y = rnorm(n))
```
这就是它的样子就像在那么结束:
I want to have my YAML header information centered on my html document.
I want everything else left alligned as normal.
Can I apply any html or other code to the YAML header to make this happen?
How do I do this??
Example:
I have:
---
title: "Shiny HTML Doc"
author: "theforestecologist"
date: "Apr 14, 2017"
output: html_document
runtime: shiny
---
解决方案
Here is some css styling that you can use to accomplish what you need.
- The markdown document title uses the
h1.title
CSS selector - The markdown document author field uses the
h4.author
CSS selector - The markdown document datea field uses the
h4.date
CSS selector
Here is the code:
---
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))
```
And this is what it looks like in then end:
这篇关于如何将我的YAML标题置于R markdown html文档中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文