我正在写一篇使用rmarkdown、knitr和rticles package的论文。这篇论文将提交给PLOS ONE,我正在使用rticles R包中提供的PLOS ONE LaTeX模板。
PLOS ONE要求数字标题以文本形式出现(数字应出现在文本中),而数字应与主手稿分开上传。
因此,我想知道是否有一种方法可以在使用knitr生成的PDF文件中包含图形标题,而不包含绘图?
下面是所需结果的屏幕截图。Overleaf上也提供了LaTeX模板。

发布于 2019-09-25 00:13:01
您可以在LaTeX包caption的帮助下隐藏绘图(最初由@duckmayer建议)并添加标题
---
title: Title of submission to PLOS journal
author:
- name: Alice Anonymous
email: alice@example.com
affiliation: Some Institute of Technology
corresponding: alice@example.com
address:
- code: Some Institute of Technology
address: Department, Street, City, State, Zip
abstract: |
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
author_summary: |
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
output: rticles::plos_article
header-includes:
- \usepackage{caption}
---
# Introduction
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```{r pressure, echo=FALSE, fig.show='hide', results='asis', fig.path="plots-"}绘图(压力)
cat(“\n\captionof{ figure }{这里是一个图形标题。}\n”)
结果:

在本例中,要提交的图形的名称为plots-pressure-1.pdf
发布于 2019-09-24 22:45:21
我只需要使用块选项out.width和out.height将最终输出中的绘图缩小到维度0 x 0。(有关所有块选项,请参阅这个很棒的文档:https://yihui.name/knitr/options/#plots)。
例如:
---
title: "SO Answer"
author: "duckmayr"
date: "9/24/2019"
output: html_document
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo =真)
Here's how to make the figure with the caption but without the plot:
```{r pressure, fig.cap='Here is a figure caption.', out.width=0, out.height=0}绘图(压力)

更新:绘图文件在哪里?
如果添加像这样的行
knitr::opts_chunk$set(fig.path = "figures/")对于上面的setup块,绘图将保存在figures/子目录中。例如,在编织之后
---
title: "SO Answer"
author: "duckmayr"
date: "9/24/2019"
output: html_document
---
```{r setup, include=FALSE}knitr::opts_chunk$set(echo =真)
knitr::opts_chunk$set(fig.path =“图形/”)
Here's how to make the figure with the caption but without the plot:
```{r pressure, fig.cap='Here is a figure caption.', out.width=0, out.height=0}绘图(压力)
我可以在~/figures/中看到这些文件
[duckmayr@duckmayr-pc ~]$ ls ~/figures/
pressure-1.png(由于您正在编织为PDF,因此默认情况下,您的绘图图像也将保存为PDF,而不是PNG)。
https://stackoverflow.com/questions/58082093
复制相似问题