图标题,使用knitr和markdown到html的引用 [英] figure captions, references using knitr and markdown to html

查看:80
本文介绍了图标题,使用knitr和markdown到html的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Rmd文件,该文件将由knitr处理为HTML.它包含一些R块,这些块可以生成图形,然后将其存储为HTML中的数据URI.

I'm writing an Rmd file, to be processed by knitr into HTML. It contains some R chunks that generate figures, which get stored as data URIs in HTML.

1)如何为此类图像添加标题?我想要一个标题,上面写着类似图3:等等等等"的标题,其中会自动生成"3".

1) How do I add a caption to such an image? I'd like to have a caption that says something like "Figure 3: blah blah blah", where the "3" is automatically generated.

2)以后我该如何参考该图像,即如图3所示,等等".

2) How do I later on reference this image, i.e., "as you can see in Figure 3, blah blah".

推荐答案

  1. 您可以在R中使用一个简单的计数器来创建图形编号;请参见此处的一个示例.问题是markdown渲染器是否会为您渲染图形标题:R Markdown v1不会,但 v2 (基于Pandoc).
  2. 我不知道.没有直接的方法可以插入标签作为图形的标识符,因此可能无法使用纯Markdown来交叉引用图形.一旦遇到此类问题,请思考(1)我真的需要吗? (2)如果打算成为结构复杂的文档,我认为最好直接使用LaTeX(Rnw文档).
  1. You can create the figure numbers with a simple counter in R; see one example here. The problem is whether the markdown renderer will render the figure caption for you: R Markdown v1 won't, but v2 (based on Pandoc) will.
  2. I do not know. There is no direct way to insert a label as an identifier for figures, so it is probably not possible to cross reference figures with pure Markdown. Once you've got issues like this, think (1) do I really need it? (2) if it is intended to be a document with a complicated structure, I think it is better to use LaTeX directly (Rnw documents).

这篇关于图标题,使用knitr和markdown到html的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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