0
votes

In writing papers for publication it is often required to keep figures in a separate document (or even a separate document for each figure). In doing so you must manually maintain the figure labels in text i.e. you must write "y was greater than 50% (Figure 1)" in the rmd document rather than something like "y was greater than 50% (Figure @ref(fig:Fig1))". This means that if the figures are rearranged, which is common, then you must manually change all the figure labels to suit the new order.

I am trying to find a way to code in rmd (officedown) that keeps the automatic numbering of the figures within the text but doesn't actually compile the word doc with the figure images.

Below is some example code, I have tried various argument such as fig.show='hide' but without success.

Any and all comments and ideas are welcome in getting to the end result. For example, cross referencing such as in book down in this question. Ideally I would also be able to leave a small amount of text where the actual figure would go as well. Something like 'Figure 1, here' as a simple marker for reviewers but this can be done manually with ease.

---
citation_package: natbib
bibliography: './CompileResources/SBLitRev_Bibli.bib'
biblio-style: 'User/Zotero/styles/ecology-letters.csl'
output:
  officedown::rdocx_document:
    reference_docx: "./CompileResources/template.docx"
  page_size:
    width: 8.3
    height: 11.7
    orient: "portrait"
  page_margins:
    bottom: 1
    top: 1
    right: 1.25
    left: 1.25
    header: 0.5
    footer: 0.5

---

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

fp <- fp_par(
  text.align = "center", 
  padding.bottom = 20, padding.top = 120, 
  border.bottom = fp_border())```

y was greater than 50% (Figure \@ref(fig:Fig1)).

*Figure 1, here*

```{r fig.cap="Bla bla", include=F, fig.id = "Fig1", fig.cap.style = "Image Caption", fig.show='hide'}

knitr::include_graphics("./Figures/Fig1.pdf")```