我正在尝试按this pandoc example将多个作者添加到yaml metadata block中的Rmarkdown文件中。 pdf将在RStudio(版本0.98.932)中生成,但没有作者信息。
---
title: 'This is the title: it contains a colon'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
我还想更多地定制标题并添加字幕。可能的?
答案 0 :(得分:40)
我刚刚发现可以在R markdown PDF输出中添加字幕。我在Ubuntu 14.04中使用R 3.2.2和RStudio 0.99.473。
---
title: 'This is the title: it contains a colon'
subtitle: 'This is the subtitle'
output: pdf_document
---
答案 1 :(得分:36)
rmarkdown中的默认乳胶模板不支持作者关联或字幕。它确实支持多个作者,但正确的yaml语法是
---
title: 'This is the title: it contains a colon'
author:
- Author One
- Author Two
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output:
pdf_document:
template: NULL
---
如果您想自定义标题,最好的方法是修改乳胶模板found here以满足您的需求。然后将其复制到本地目录并将其传递到template
字段中的标头。
答案 2 :(得分:9)
如果你渲染一个pdf,LaTex会使用作者'从属关系的脚注(即转换symbles中的编号)。尝试
---
title: 'This is the title: it contains a colon'
subtitle: 'This is the subtitle'
author:
- Author One^[University of Somewhere]
- Author Two^[University of Nowhere]
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
答案 3 :(得分:6)
我也遇到过这个问题。根据@ tmpname12345的建议,我修改了乳胶模板(default.tex)和html模板(default.html)来渲染字幕。如果你想快速获得代码,这个拉取请求就在github rstudio/rmarkdown上,并且看起来它在下次推送到CRAN时将成为rmarkdown的标准。
答案 4 :(得分:5)
我在这里找到了问题的字幕解决方案:https://stackoverflow.com/a/41444545/14027216
您可以通过在代码中添加subtitle:
来添加字幕,并且可以添加多个字幕,如下所示:
---
title: 'This is the title: it contains a colon'
subtitle: |
| 'subtitle 1'
| 'subtitle 2'
author:
- name: Author One
affiliation: University of Somewhere
- name: Author Two
affiliation: University of Nowhere
date: "`r format(Sys.time(), '%d %B %Y')`"
tags: [nothing, nothingness]
abstract: |
This is the abstract.
It consists of two paragraphs.
output: pdf_document
---
您可以添加两个以上的字幕,但是我不知道最大数量。每个字幕将以换行显示。
答案 5 :(得分:4)
如主要答案中所述,默认的R Markdown模板不支持作者隶属关系。虽然用户可以编辑模板文件以添加自己的自定义YAML字段,但是可以使用一些更简单的解决方法来处理PDF或HTML输出。
您可以使用最近发布的radix template。首先,您必须安装该软件包:
install.packages("radix")
安装后,您必须设置
---
title: "Radix for R Markdown"
description: |
Scientific and technical writing, native to the web
date: May 4, 2018
author:
- name: "JJ Allaire"
url: https://github.com/jjallaire
affiliation: RStudio
affiliation_url: https://www.rstudio.com
- name: "Rich Iannone"
url: https://github.com/rich-iannone
affiliation: RStudio
affiliation_url: https://www.rstudio.com
output: radix::radix_article
---
Your content
您可以使用预制模板,并且 rticles 包中有一些很好的示例。首先,我们必须安装该软件包:
install.packages("rticles")
安装后,您可以使用模板之一,例如Journal of Statistics Software:
---
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \email{name@company.com}
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \\pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
output: rticles::jss_article
---
答案 6 :(得分:3)
添加Ze Grisi的答案,我刚刚发现在yaml中添加html标题标签以调整标题和副标题中的字体。请注意,不再需要引号。
---
title: 'This is the title: it contains a colon'
subtitle: <h1>This is the subtitle</h1>
output: pdf_document
---
为了获得更具戏剧性的效果,请在字幕
中添加下划线---
title: 'This is the title: it contains a colon'
subtitle: <h1><u>This is the subtitle</u></h1>
output: pdf_document
---
答案 7 :(得分:0)
在{g {3}}中使用@greg的乳胶解决方案。我将乳胶代码放入 rmarkdown yaml标头 进行了一些更改,就可以了。
---
title: 'Some Title'
author: Author One$^1$ \and
Author Two$^2$ \and
Author Three$^3$
date: $^1$Organization 1 \newline
$^2$Organization 2 \newline
$^3$Organization 3
\newline
\newline
\today
output:
---
技巧是将从属关系放入日期标签。