r2typ provides functions to help you write and compile your Typst markup.
Please note that you must have the Typst compiler installed and on PATH (running typst compile file.typ in your terminal must work).
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.