Lay out and render a single TFL page
export_tfl_page.RdRenders a single page with up to five vertical sections: header, caption, content, footnote, and footer. Section heights are computed dynamically from font metrics so that the content area occupies all remaining space. All layout errors (overlapping elements, content area too short) are collected and reported together before any drawing occurs.
Usage
export_tfl_page(
x,
padding = grid::unit(0.5, "lines"),
header_left = NULL,
header_center = NULL,
header_right = NULL,
caption = NULL,
footnote = NULL,
footer_left = NULL,
footer_center = NULL,
footer_right = NULL,
gp = grid::gpar(),
header_rule = FALSE,
footer_rule = FALSE,
caption_just = "left",
footnote_just = "left",
margins = grid::unit(c(t = 0.5, r = 0.5, b = 0.5, l = 0.5), "inches"),
min_content_height = grid::unit(3, "inches"),
page_i = NULL,
preview = FALSE,
...
)Arguments
- x
A list with a required
contentelement (aggplotobject or any grid grob, e.g. fromgt::as_gtable()orgridExtra::tableGrob()) and optional text elements:header_left,header_center,header_right,caption,footnote,footer_left,footer_center,footer_right. List elements take precedence over the corresponding direct arguments.- padding
Vertical space between adjacent present sections, as a
unitobject. Separator rules (if enabled) are drawn at the midpoint of this gap and do not consume additional space.- header_left, header_center, header_right
Header text. Accepts
NULL, a single string, or a character vector (collapsed with"\\n"). Horizontal justification follows the argument name (left/center/right). Vertically top-justified. Overridden byx$header_leftetc.- caption
Caption text below the header and above the content. Accepts
NULL, a single string, or a character vector. Full-width; justification controlled bycaption_just. Overridden byx$caption.- footnote
Footnote text below the content. Accepts
NULL, a single string, or a character vector. Full-width; justification controlled byfootnote_just. Overridden byx$footnote.Footer text. Mirror of header arguments. Vertically bottom-justified. Overridden by
x$footer_leftetc.- gp
Typography specification. Accepts either a single
gpar()object applied to all text, or a named list for section- or element-level control. Resolution priority (highest first): element-level (e.g.gp$header_left), section-level (e.g.gp$header), globalgpar(). Example:- header_rule
Separator rule drawn between the header and the next section (caption or content), fitted within the
paddinggap. Accepts:FALSE: no ruleTRUE: full-width ruleA numeric in
(0, 1]: rule spanning that fraction of viewport width, centeredA grob (typically a
linesGrob): drawn as-is, centered vertically in the padding gap.
Separator rule between the last body section (footnote or content) and the footer. Same specification as
header_rule.- caption_just
Horizontal justification for the caption.
- footnote_just
Horizontal justification for the footnote.
- margins
Outer page margins as a
unitvector with elementst,r,b,l(top, right, bottom, left).- min_content_height
Minimum acceptable content area height as a
unitobject. An error is raised if the computed content height falls below this value.- page_i
Integer page index, used to prefix layout error messages with
"Page <i>: ". Set automatically byexport_tfl(); not normally supplied when calling this function directly.- preview
Logical. If
TRUE, callsgrid.newpage()and draws to the currently open device without opening or closing any device.- ...
Additional arguments. Currently recognised:
overlap_warn_mm: numeric threshold in mm for near-miss overlap warnings. Set toNULLto disable.
See also
export_tfl() for multi-page PDF export.