Home > Software engineering >  how to add greek letters to nomnoml diagram in R
how to add greek letters to nomnoml diagram in R

Time:05-18

I am using the nomnoml package to create diagrams in combination with rmarkdown. How can I add greek letters to my arrows?

I have naively tried the following

---
title: "Nomnoml Diagram"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(nomnoml)
```

```{nomnoml, svg=TRUE}
[a]-> \alpha [b]
[c]-> \u03be [d]
```

Both do not work.

CodePudding user response:

It works if you just paste α into RStudio, like this:

```{nomnoml, svg=TRUE}
[a]->α[b]
```

If you don't find α on your keyboard you can write "\u03B1" in the console and copy the output.

Full working document:

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(nomnoml)
```

```{nomnoml, svg=TRUE}
[a]->α[b]
```

CodePudding user response:

I think if you want to use Unicode escapes in the source, you will have to use an R code chunk instead of a nomnoml code chunk. For example,

---
title: "Untitled"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(nomnoml)
```

```{r echo=FALSE}
nomnoml("[a]->\u03B1[b]", svg = TRUE)
```
  • Related