重新开始对簿记中的附录/辅助材料进行图形编号 [英] Restart Figure Numbering for Appendix / Supplementary Material in bookdown

查看:12
本文介绍了重新开始对簿记中的附录/辅助材料进行图形编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为一家需要补充材料的期刊写一篇文章。我希望使用唯一的标签(如SuppMat:)而不是默认的fig:将图形和表格发送到此部分。如果没有,我可以使用默认的fig标签,但我需要在文档的补充材料部分重新开始编号。

我知道使用LaTeX(Foundhere)有一个答案,但在导出到docx时必须完成此操作。以下是使用officedown

---
output: 
  officedown::rdocx_document
---

```{r setup, include=FALSE}
pacman::p_load(knitr, officedown, officer)
knitr::opts_chunk$set(echo = FALSE,
                      eval = TRUE,
                      fig.cap = TRUE)
```

# Main Text

Please see Supplementary Figure @ref(fig:appendix-fig1) and Figure @ref(fig:main-fig1). 


```{r fig.id="main-fig1", fig.cap="This should be labelled **Figure 1**"}
barplot(1:5, col=1:5)
```

```{r tab.id="main-tab1", tab.cap="Main Text Table 1"}
head(mtcars)
```

ewpage

# Supplementary Materials {#SuppMat}

```{r fig.id="appendix-fig1", fig.cap="This figure should be labelled **Supplementary Figure 1**"}
barplot(1:5, col=1:5)
```

```{r tab.id="appendix-tab1", tab.cap="Should be labelled **Supplementary Table 1**"}
head(mtcars)
```

推荐答案

在搜索多个论坛和小时后,我能够使用officedown包提出解决方案。希望这能帮助其他人。有关详细信息,请查看run_autonum函数。

---
output: officedown::rdocx_document
---

```{r setup, include=FALSE}
pacman::p_load(officedown, officer, knitr)
knitr::opts_chunk$set(echo = FALSE, fig.cap = TRUE)


ft_base <- fp_text(font.family = "Cambria", font.size = 12, bold = TRUE)
ft1 <- update(ft_base, shading.color='#EFEFEF', color = "red")
ft2 <- update(ft_base, color = "#C32900")

srcfile <- file.path( R.home("doc"), "html", "logo.jpg" )
extimg <- external_img(src = srcfile, height = 1.06/5, width = 1.39/5)
```



## References

This is a reference to an supplementary image caption whose number is Supplementary Figure @ref(fig:faithfuld-plot) and @ref(fig:supp-bar).

Testing another figure with a barplot in Figure @ref(fig:plotbar)

```{r fig.id="plotbar", fig.cap = "Main Figure"}
barplot(1:8, col=1:2)
```

## Supplementary Material

```{r fig.id="faithfuld-plot"}
knitr::include_graphics("images/MyImage.png") # Use your own figure here (I needed to test with knitr for my workflow)

block_caption("First Appendix Figure",
              style = "Figure",
              autonum = run_autonum(seq_id = 'fig', 
                                    bkm = 'faithfuld-plot',
                                    pre_label = "Supplemental Figure ",
                                    start_at=1))
```

```{r fig.id="supp-bar"}
barplot(1:8, col=1:2)

block_caption("Second Appendix Figure",
              style = "Figure",
              autonum = run_autonum(seq_id = 'fig', 
                                    bkm = 'supp-bar',
                                    pre_label = "Supplemental Figure ",
                                    start_at= NULL))
```

这篇关于重新开始对簿记中的附录/辅助材料进行图形编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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