tikzsave: Save a tikzpicture and then compile to pdf

View source: R/tikzsave.R

tikzsaveR Documentation

Save a tikzpicture and then compile to pdf

Description

Uses ggplot2::ggsave with tikzDevice::tikz to create the tikz figure and then compiles using latexmk.

Usage

tikzsave(
  filename,
  plot = ggplot2::last_plot(),
  packages = NULL,
  pre_begin_document = NULL,
  recompile = TRUE,
  create_png = FALSE,
  quiet = TRUE,
  ...
)

Arguments

filename

File name to create on disk.

plot

Plot to save, defaults to last plot displayed.

packages

Vector of strings. If no ⁠\⁠ is detected, then this is assumed to be an absolute file paths to a .sty file to include in preamble. Default is my paper.sty and math.sty in inst/tikzsave.

pre_begin_document

Verbatim text to include right before ⁠\begin{document}⁠

recompile

Logical. Since tikzDevice::tikz caches effectively, sometimes the .pdf file will be newer than the saved .tex file. If FALSE, this will skip recomipilation in these cases. Default is TRUE.

create_png

Logical. If true, will also output a png in addition to the pdf.

quiet

Logical. If TRUE (default), do not display info messages.

...

Passed to ggplot2::ggsave

Value

Invisibly returns filename


kylebutts/kfbmisc documentation built on April 17, 2025, 5:20 p.m.