渲染降价文件时,标题未显示在带有编织器的R Markdown上 [英] Title not showing on R Markdown with knitr when rendering markdown file

查看:61
本文介绍了渲染降价文件时,标题未显示在带有编织器的R Markdown上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将.Rmd文件转换为.md(输出:md_document),但是标题未显示在渲染的文件上.

I am trying to convert a .Rmd file to .md (output: md_document), but the title does not show up on the rendered file.

当我尝试呈现与.html文件相同的文件时,标题确实出现了(输出:html_document).

The title does show up when I try to render the same file as an .html file (output: html_document).

标题显示在渲染的文档上

Title shows up on rendered document:

---
title: "Test"
output: html_document
---

```{r}

head(cars)
```


标题未显示在渲染的文档上

Title does not show up on rendered document:

---
title: "Test"
output: md_document
---

```{r}

head(cars)
```


rmarkdown::render(my_file)

有什么想法吗?

我在Mac 10.9.5上使用RStudio 0.98.1091和R 3.1.2.

I am using RStudio 0.98.1091 and R 3.1.2 on a Mac 10.9.5.


--之间的代码被解释,因为我的引用使用以下代码呈现:

The code in between -- gets interpreted, as my references are rendered with the following piece of code:

---
title: "Test"
output: md_document
bibliography: ~/mybib.bib
---

This is a test where I cite [@post1, @post2]


有趣的是,当我要求生成html和md文件时,标题显示在.md文件上:

The interesting thing is that when I ask for both the html and md files to be generated, the title shows up on the .md file:

---
title: "Test"
output:
  html_document:
    keep_md: yes
---

keep_md: yes的输出应该与output: md_document相同吗?

Shouldn't the output of keep_md: yes be the same as output: md_document?

推荐答案

Markdown没有标题"这样的概念. HTML具有<title>标记(Pandoc还将Markdown的标题放在<h1>中,以便从Markdown输出HTML,以便可以从HTML正文中看到它),而LaTeX具有\title{}命令.对于我来说,YAML元数据(包括标题信息)没有反映在Markdown输出中并不奇怪.

Markdown does not have such a concept as "title". HTML has the <title> tag (and Pandoc also puts the title in <h1> for the HTML output from Markdown so you can see it from the HTML body), and LaTeX has the \title{} command. It is not unexpected to me that the YAML metadata (including the title info) is not reflected in the Markdown output.

这篇关于渲染降价文件时,标题未显示在带有编织器的R Markdown上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆