Assembles a Quarto knitr figure chunk.
Usage
fig_chunk(
body,
label,
fig_cap = NULL,
fig_subcap = NULL,
fig_column = NULL,
fig_width = NULL,
fig_height = NULL,
fig_pos = "H",
fig_link = NULL,
column = NULL,
out_width = NULL,
out_height = NULL
)
Arguments
- body
R code to insert into the code chunk's body. A character scalar.
- label
Unique code chunk label. Set as Quarto's
label
code chunk option. A character scalar that starts with"fig-"
and only contains letters, numbers, underscores (_
) and dashes (-
).- fig_cap
Figure caption. Set as Quarto's
fig-cap
code chunk option. EitherNULL
to omit or a character vector.- fig_subcap
Figure subcaptions. Set as Quarto's
fig-subcap
code chunk option. EitherNULL
to omit or a character vector.- fig_column
Quarto article layout class for the figure output. Set as Quarto's
fig-column
code chunk option. EitherNULL
to omit or one of"body"
"body-outset"
"body-outset-left"
"body-outset-right"
"page"
"page-left"
"page-right"
"page-inset-left"
"page-inset-right"
"screen"
"screen-left"
"screen-right"
"screen-inset"
"screen-inset-shaded"
"screen-inset-left"
"screen-inset-right"
"margin"
- fig_width
Width of the plot (in inches), to be used in the graphics device. Set as Quarto's
fig-width
code chunk option. EitherNULL
to omit or a numeric scalar.- fig_height
Height of the plot (in inches), to be used in the graphics device. Set as Quarto's
fig-height
code chunk option. EitherNULL
to omit or a numeric scalar.- fig_pos
LaTeX figure position arrangement to be used in
\begin{figure}[]
. Set as Quarto'sfig-pos
code chunk option. EitherNULL
to omit, a character scalar, orFALSE
for no figure position specifier, which is sometimes necessary with custom figure environments (such assidewaysfigure
).- fig_link
Hyperlink target for the figure. Set as Quarto's
fig-link
code chunk option. EitherNULL
to omit or a character scalar.- column
Quarto article layout class for all of the code chunk's output. Set as Quarto's
column
code chunk option. EitherNULL
to omit or one of"body"
"body-outset"
"body-outset-left"
"body-outset-right"
"page"
"page-left"
"page-right"
"page-inset-left"
"page-inset-right"
"screen"
"screen-left"
"screen-right"
"screen-inset"
"screen-inset-shaded"
"screen-inset-left"
"screen-inset-right"
"margin"
- out_width
Width of the plot in the output document, which can be different from its physical
fig_width
, i.e., plots can be scaled in the output document. Set as Quarto'sout-width
code chunk option. EitherNULL
to omit or a character scalar.- out_height
Height of the plot in the output document, which can be different from its physical
fig_height
, i.e., plots can be scaled in the output document. Set as Quarto'sout-height
code chunk option. EitherNULL
to omit or a character scalar.
Details
Use substitute together with deparse1()
to convert R expressions to a character scalar as expected by param body
:
deparse1(expr = substitute(do_something()),
collapse = "\n")
See also
Other code chunk functions:
chunks()
,
read_chunk_toml()
,
tbl_chunk()