繁体   English   中英

使用knitr和pandoc创建docx文件时,有没有办法隐藏图标?

[英]Is there a way to hide figure captions when using knitr and pandoc to create docx files?

我正在使用knitr和pandoc将报告写入单词(我们需要能够使用跟踪更改来传播评论等)。

它到目前为止工作得非常好,但我发现这些情节都是底部带有字幕的,我不想要字幕。 虽然我可以在单词doc中删除它们,但如果我可以阻止它们在代码中显示它会更好。

因此,对于markdown中的以下代码:

Test test test

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r fig.width=7, fig.height=6}
plot(cars)
```

然后我在R中运行以下代码:

library("knitr")

# Stackoverflow table test 1.html

knit2html("captiontest.rmd")

FILE <- "captiontest"

system(paste0("pandoc -o ", FILE, ".docx ", FILE, ".md"))

而word文档中的图表标题为“chunk unnamed-chunk-2”

我知道我可以改变这个标题,例如{r fig.width=7, fig.height=6, fig.cap='hello'} ,但我认为fig.cap=NULL会让它隐藏起来。 相反,它似乎使整个情节消失。

情节是否需要有标题 - 我是否只需要浏览每个单词doc并手动删除它们? 或者有办法隐藏它们吗?

有点肮脏的把戏,但是:

你可以在有问题的块上设置fig.cap=""

Test test test

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r fig.width=7, fig.height=6, fig.cap=""}
plot(cars)
```

或者,您可以在Rmd文档开头的初始化块中一次为所有块设置fig.cap=""

Test test test

```{r options-chunk} 
opts_chunk$set(fig.cap="")
``` 

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r fig.width=7, fig.height=6}
plot(cars)
```

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM