I have an R markdown document with officer
and officedown
. In this I would like to use custom references.
<code>---
output:
officedown::rdocx_document:
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
if (!require("pacman")) install.packages("pacman"); library(pacman)
pacman::p_load(officer, officedown)
fp_text_ref <- fp_text_lite(font.size = 11, font.family = "Calibri", color = "red")
fp_text_cap <- fp_text_lite(font.size = 10, font.family = "Calibri")
```
This is a reference to `r run_reference(id = "figure1", prop = fp_text_ref)`.
```{r figure1, echo = F}
plot(mtcars)
fpar(
run_autonum(seq_id = 'fig', bkm = 'figure1', pre_label = "Figure ", bkm_all = TRUE, prop = fp_text_cap),
ftext(paste0("Caption"), prop = fp_text_cap),
fp_p = fp_par(text.align = "justify", line_spacing = 1.15)
)
```
</code>
<code>---
output:
officedown::rdocx_document:
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
if (!require("pacman")) install.packages("pacman"); library(pacman)
pacman::p_load(officer, officedown)
fp_text_ref <- fp_text_lite(font.size = 11, font.family = "Calibri", color = "red")
fp_text_cap <- fp_text_lite(font.size = 10, font.family = "Calibri")
```
This is a reference to `r run_reference(id = "figure1", prop = fp_text_ref)`.
```{r figure1, echo = F}
plot(mtcars)
fpar(
run_autonum(seq_id = 'fig', bkm = 'figure1', pre_label = "Figure ", bkm_all = TRUE, prop = fp_text_cap),
ftext(paste0("Caption"), prop = fp_text_cap),
fp_p = fp_par(text.align = "justify", line_spacing = 1.15)
)
```
</code>
---
output:
officedown::rdocx_document:
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
if (!require("pacman")) install.packages("pacman"); library(pacman)
pacman::p_load(officer, officedown)
fp_text_ref <- fp_text_lite(font.size = 11, font.family = "Calibri", color = "red")
fp_text_cap <- fp_text_lite(font.size = 10, font.family = "Calibri")
```
This is a reference to `r run_reference(id = "figure1", prop = fp_text_ref)`.
```{r figure1, echo = F}
plot(mtcars)
fpar(
run_autonum(seq_id = 'fig', bkm = 'figure1', pre_label = "Figure ", bkm_all = TRUE, prop = fp_text_cap),
ftext(paste0("Caption"), prop = fp_text_cap),
fp_p = fp_par(text.align = "justify", line_spacing = 1.15)
)
```
However, the output word document displays the references generated by run_reference()
with the formatting of fp_text_cap
instead of fp_text_ref
. What do I need to change so that run_reference()
is displayed with the fp_text_ref
formatting?
Recognized by R Language Collective
I did some tests with Word (Version 16.88) and it seems this is not possible anymore. When the reference is calculated by Word, it uses the format of the target field. So fp_text_cap
is used, the only way to change it seems to do it manually.
1