Skip to contents

r2typ provides functions to help you write and compile your Typst markup, without you having to worry about installing Typst.1

We can write a typst file using typst_write():

typst_code <- c("= Hello World", "This is a Typst document.")
output_file <- typst_write(typst_code)

Then we can compile this file to PDF with typst_compile():

typst_compile(output_file)

Control file names

Both typst_write() and typst_compile() have an optional output arguments to control file names:

typst_code <- c("= Hello World", "This is a Typst document.")
output_file <- typst_write(typst_code, "here.typ")
typst_compile(output_file, "report.pdf")

r2typ also offers a is_valid_typst() that returns TRUE/FALSE depending on if the code can be compiled or not. Check out that the dedicated vignette.