When I run the R script below in RStudio, the theta is shown correctly.
---
title: "test"
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidygraph)
library(ggraph)
```
# Greek letters
```{r ggraph}
nodes<-data.frame(label=c("θ","S"))
edges<-data.frame(from=c(2),to=c(1))
graph<-tbl_graph(nodes=nodes,edges=edges)
ggraph::ggraph(graph,layout="fr")+
ggraph::geom_edge_link()+
ggraph::geom_node_label(mapping = aes(label=label))
```
But when I knit it, I get this error message (partly in Danish):
! Package inputenc Error: Unicode character θ (U+03B8) (inputenc) not set up for use with LaTeX.
Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. For R Markdown users, see https://bookdown.org/yihui/rmarkdown/pdf-document.html Fejl: LaTeX failed to compile test.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test.log for more info. In addition: Advarselsbeskeder: 1: I grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 2: I grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 3: I grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 4: I grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 5: I grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 6: I grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 7: I grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for 8: I grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
konverteringsfejl på 'θ' i 'mbcsToSbcs': punktum erstattet for Kørsel stoppet
I have tried using expression(theta) instead of the character itself, but that doesn't work. Any ideas?