Skip to contents

Captures the currently drawn grid scene, converts it to CeTZ commands, and writes a .typ file.

Usage

grid_to_cetz(
  filename = "Rplot.typ",
  header = NULL,
  footer = NULL,
  cetz_version = "0.4.2",
  page_width = "auto",
  page_height = "auto",
  emit_panel_meta = TRUE,
  embed_panel_shift = FALSE,
  quiet = TRUE,
  escape_hash = FALSE
)

Arguments

filename

Output .typ file path. Default is "Rplot.typ".

header

Optional Typst header text. If NULL, a default header is used.

cetz_version

CeTZ version string. Default is "0.4.2".

page_width, page_height

Typst page dimensions. Defaults are "auto".

Value

The Typst source string, invisibly.

Examples

grid::grid.newpage()
grid::grid.rect(gp = grid::gpar(fill = "grey95"))
grid::grid.text("Scene exported with grid_to_cetz()")

out <- tempfile(fileext = ".typ")
src <- grid_to_cetz(out)

file.exists(out)
#> [1] TRUE
is.character(src)
#> [1] TRUE