【问题标题】:Are knitr subcaptions only for Latex?knitr subcaptions 仅适用于 Latex 吗?
【发布时间】:2013-05-06 11:00:16
【问题描述】:

我在 Windows 7 中使用 RStudio/knitr/markdown/pandoc/docx。当我并排打印其中两个时,我无法在我的图上获取标题。
在以下示例中,我的 docx 中没有中间图形的标题。不过,最后一张图中的数字是正确的。

顺便说一句,当我不包含 fig.subcap 选项时,我也没有得到标题。
谢谢!

Title
========================================================


```{r setup, include=FALSE}
opts_chunk$set(comment=NA)

fig.caption.num = local({
  i = 0
  function(x) {
    i <<- i + 1
    paste('Fig. ', i, ': ', x, sep = '')
  }
})
```

Some text:  

```{r fig.width=7, fig.height=6, fig.cap=fig.caption.num('My first plot')}
plot(cars)
```


Two plots:  

```{r fig.width=3, fig.height=7, fig.cap=fig.caption.num('Two plots'), fig.show='hold', fig.subcap=c('one plot', 'the other one')}
plot(cars)
plot(1:10)
```


Some more text:  

```{r fig.width=7, fig.height=7, fig.cap=fig.caption.num('My last plot')}
plot(cars)
```


Finish text  

sessionInfo()
R 版本 2.15.3 (2013-03-01) 平台:x86_64-w64-mingw32/x64(64位)

locale:
[1] LC_COLLATE=Spanish_Argentina.1252  LC_CTYPE=Spanish_Argentina.1252   
[3] LC_MONETARY=Spanish_Argentina.1252 LC_NUMERIC=C                      
[5] LC_TIME=Spanish_Argentina.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] digest_0.6.3   evaluate_0.4.3 formatR_0.7    knitr_1.2      stringr_0.6.2 
[6] tools_2.15.3  

【问题讨论】:

  • 是的,这是 LaTeX 独有的功能
  • 谢谢亿辉!我认为问题已回答,您愿意这样发布吗?如果您愿意,我会在几天后将其标记为自己回答并参考您的评论。

标签: markdown knitr


【解决方案1】:

这只是为了将问题标记为已回答。请参阅上面 Yihui 的评论,确认这是一个仅限 LaTeX 的功能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    • 1970-01-01
    • 2019-11-15
    相关资源
    最近更新 更多