---
title: Using r2typ in Quarto documents
vignette: >
  %\VignetteIndexEntry{using-r2typ-in-quarto-documents}
  %\VignetteEngine{quarto::html}
  %\VignetteEncoding{UTF-8}
knitr:
  opts_chunk:
    collapse: true
    comment: '#>'
    message: false
---

`{r2typ}` will output valid format for your Quarto documents assuming you have the `{knitr}` package installed, which is probably the case.

## Basic usage

````md
---
title: "{r2typ} demo"
format: typst
---

This is a demo of the `{r2typ}` package.

```{{r}}
library(r2typ)
```

## Simple usage

```{{r}}
heading(level = 2, numbering = "1.1", "Hello world")
```

## Using show rule

```{{r}}
show_heading(set_text(fill = red))
heading(level = 2, numbering = "1.1", "Hello world")
```
````

![](./r2typ-with-quarto-output.png)

## Advanced usage

`{r2typ}` becomes very interesting when using dynamic values and advanced function calls. For example, here we use a parameter and add it inside the text of a circle:

````md
---
title: "{r2typ} demo"
format: typst
params:
  country: Germany
---

This is a demo of the `{r2typ}` package.

```{{r}}
library(r2typ)
library(glue)
```

## Complex usage

```{{r}}
align(
  center + horizon,
  circle(
    width = percent(40),
    fill = aqua,
    stroke = pt_(5) + rgb_("#ffc300"),
    align(
      right,
      text_(
        font = "Roboto",
        size = em(1.2),
        fill = purple,
        glue("My favorite country is {params$country}")
      )
    )
  )
)
```
````

![](./r2typ-with-quarto-output-2.png)