How to include greek symbols in a block_caption in officer R markdown Word doc?

30 Views Asked by At

I am trying to include a greek symbol in my block_caption() in the officer R package (writing to docx), but the greek symbol is not formatting.

I have tried:

--
title: 'Test'
output:
  officedown::rdocx_document:
  html_document:
    df_print: paged
includeline-num: true
---

# Test
  
```{r test, echo=FALSE, fig.height=6, fig.width=6}

#from https://stackoverflow.com/questions/54915628/restart-figure-numbering-for-appendix-supplementary-material-in-bookdown
officer::block_caption("\\sigma",
                       style = "Figure",
                       autonum = officer::run_autonum(seq_id = 'suppfig', 
                                                      bkm = 'test',
                                                      pre_label = "Supplementary Figure ",
                                                     start_at=NULL))

```

However, when I knit this to Word, the caption just outputs at "\sigma". Can anyone provide the correct solution please as I can't find one anywhere? Thanks!

1

There are 1 best solutions below

1
stefan On

One option to add a sigma symbol would be to use it's UTF-8 code = \u003c.

---
title: 'Test'
output:
  officedown::rdocx_document:
  html_document:
    df_print: paged
includeline-num: true
---

# Test
  
```{r test, echo=FALSE, fig.height=6, fig.width=6}
# from https://stackoverflow.com/questions/54915628/restart-figure-numbering-for-appendix-supplementary-material-in-bookdown
officer::block_caption("\u03c3",
  style = "Figure",
  autonum = officer::run_autonum(
    seq_id = "suppfig",
    bkm = "test",
    pre_label = "Supplementary Figure ",
    start_at = NULL
  )
)
```

enter image description here