fig_path: Path for figure files

View source: R/utils.R

fig_pathR Documentation

Path for figure files

Description

The filename of figure files is the combination of options fig.path and label. This function returns the path of figures for the current chunk by default.

Usage

fig_path(suffix = "", options = opts_current$get(), number)

Arguments

suffix

A filename suffix; if it is non-empty and does not contain a dot ., it will be treated as the filename extension (e.g. png will be used as .png)

options

A list of options; by default the options of the current chunk.

number

The current figure number. The default is the internal chunk option fig.cur, if this is available.

Value

A character vector of the form ‘fig.path-label-i.suffix’.

Note

When there are special characters (not alphanumeric or ‘⁠-⁠’ or ‘⁠_⁠’) in the path, they will be automatically replaced with ‘⁠_⁠’. For example, ‘a b/c.d-’ will be sanitized to ‘a_b/c_d-’. This makes the filenames safe to LaTeX.

Examples

fig_path(".pdf", options = list(fig.path = "figure/abc-", label = "first-plot"))
fig_path(".png", list(fig.path = "foo-", label = "bar"), 1:10)

knitr documentation built on Sept. 11, 2024, 6:18 p.m.