gridcetz() draws a plot and writes Typst/CeTZ source to a file.
It supports two usage patterns:
Usage
gridcetz(
filename = "Rplot.typ",
expr,
width = 7,
height = 5,
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
.typfile path. Default is"Rplot.typ".- expr
Plotting expression for expression-style use.
- width, height
Device dimensions in inches. Defaults to
7and5.- 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".- embed_panel_shift
If
TRUE, emit a built-in horizontal shift in the Typst fragment based on detected panel margins. The shift can still be disabled in a document by adding#metadata(true) <disable-panel-shift>.
Details
Expression style (recommended):
gridcetz("scatter.typ", { ... })
Open/close style:
call gridcetz_open(), draw, then call gridcetz_off().
Examples
out <- tempfile(fileext = ".typ")
gridcetz(out, {
grid::grid.newpage()
grid::grid.rect(gp = grid::gpar(fill = "white"))
grid::grid.text("Hello gridcetz")
})
file.exists(out)
#> [1] TRUE