Bug in knitr / Rmarkdown for producing word document and graphics in pdf

Let try this minimal Rmarkdown file:

---
title: "cex in Rmarkdown"
output: word_document
---

```{r}
knitr::opts_chunk$set(dev='pdf')
```


```{r}
plot((0:160)/4, 0:160, type="n")
text(x=20, y=70, labels =expression(alpha), cex=1e-7)
```


When knitr-red from Rstudio (with r 3.6.1 on MacosX with knitr 1.24), it produced an error with this message ("Information of metric non available for this family") [translation from French because of my system configuration]

However,

text(x=20, y=70, labels =expression(alpha), cex=0)
and

text(x=20, y=70, labels =expression(alpha), cex=0.1)

work.

Also
text(x=20, y=70, labels ="a", cex=1e-7) works but text(x=20, y=70, labels =expression("K"["0"]), cex=1e-7) produced also an error.

The error does not occur when dev='png' is used but it occurs also for dev='postscript'.


The only solution that I found is something like that:
cexindex <- The value that you want
text(x=20, y=70, labels =expression("K"["0"]), cex=ifelse(cexindex>0.1, cexindex, 0))

Commentaires