Map page numbers to sections with headers/footers. Pages are automatically numbered based on content order (starting at 1).
Arguments
- doc
An
rtf_documentobject.- page
Where this section starts. Pages are auto-numbered from the content order (starting at 1), so this is a page number. A single integer starts one section at that page; a vector starts several sections at once (its length must match the number of sections in
secinfo).- secinfo
Superseded by
header/footer(documented, not warned): the same as a named list,list(header = , footer = ), and the way to give several sections at once – alistof such lists, one per entry ofpage. A name other thanheader/footer/watermarkis an error (it used to be ignored, the band it meant left out), and so is a header / footer that is neither anrtf_header()/rtf_footer(), its rows nor its text.The section's running header and footer: an
rtf_header()/rtf_footer(), orNULL.NULLmeans inherit: a section with no header (footer) of its own keeps the previous section's, so only the first section'sNULLleaves the pages without one. For a blank band after a section that has one, pass an empty one:rtf_header("").
See also
rtf_header() / rtf_footer() to build the header / footer, and
rtf_document() for the document and its page geometry.
Examples
df <- data.frame(Parameter = "Age, Mean (SD)", Value = "75.1 (8.2)")
h1 <- rtf_header(c(l = "Table 14.1.1", r = "Page {AUTO_PAGE} of {AUTO_TOTAL_PAGES}"))
h2 <- rtf_header(c(l = "Table 14.2.1", r = "Page {AUTO_PAGE} of {AUTO_TOTAL_PAGES}"))
ftr <- rtf_footer(c(l = "Confidential"))
# One header / footer applied to the whole document:
doc <- rtf_document() |>
rtf_tables(list(df, df)) |>
rtf_section(header = h1, footer = ftr)
# A second section, with a different header, starting at page 2:
doc <- rtf_document() |>
rtf_tables(list(df, df)) |>
rtf_section(page = 1, header = h1, footer = ftr) |>
rtf_section(page = 2, header = h2) # the footer is inherited