问题描述
我想使用代码块在文本开头插入图片,而不是降价。我正在使用Tufte讲义模板输出:rmarkdown :: tufte_handout
当我在YAML标题后直接插入它但在TOC之前插入它:
I want to insert a picture at the beginning of text using a code block, not markdown. I am using the Tufte handout template output: rmarkdown::tufte_handout
and when I insert it straight after the YAML header but before TOC like this:
\centering
![width='100%'](./cropped-banner_efpt.jpg)
\raggedright
\tableofcontents
\clearpage
图像然后跨越主体。我知道有块可以选择让块跨越整个页面,在块头中放置 fig.fullwidth = TRUE
,但是我有点卡住这个因为我没有从数据生成任何图形,我不知道如何简单地从一个块中放置图像。
the image then spans the main body. I know that with chunks there is an option to have the chunk to span the whole page placing fig.fullwidth = TRUE
in the chunk header, but I am a bit stuck with this as I am not generating any graph from data and I do not know how to simpy place an image from within a chunk.
另一个问题是当我在YAML标题中设置toc:true时,图像只会在插入的toc之后 - 这就是为什么我正在使用latex命令插入toc。
Another matter was that when I set toc: true in the YAML header, the image would only come after the inserted toc - that is why I am inserting toc with the latex command.
感谢您的建议。
推荐答案
当一个数字是不是从R代码生成的,您可以使用 knitr :: include_graphics()
将其插入到文档中,例如
When a figure is not generated from R code, you may use knitr::include_graphics()
to insert it to the document, e.g.
```{r echo=FALSE, out.width='100%'}
knitr::include_graphics('./cropped-banner_efpt.jpg')
```
这篇关于如何使用knitr从chunk中插入普通图片(jpeg / png)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!