hf_line: Create a title line container

Description Usage Arguments Value Supported Formatting Examples

View source: R/header-footer.R

Description

hf_line objects represent individual title or footnote lines and their associated metadata. These objects are passed to an rtf_doc for display in the header or footer of an RTF document.

A character vector of length <= 2 describes the text to display. Using a single text element, the text can be aligned left, right, or center. Using two text elements, the alignment can be set to “split”, which will left align the first element, and right align the second. If alignment is set to anything else, the text elements will be pasted together.

Lines can either be passed to the titles/footnotes arguments in the call to rtf_doc or added later with the add_titles or add_footnotes functions. Supported properties are detailed in the arguments section.

Usage

1
2
3
4
5
6
7
8
9
hf_line(
  ...,
  align = c("center", "left", "right", "split"),
  bold = FALSE,
  italic = FALSE,
  font = NA,
  font_size = NA,
  index = NA
)

Arguments

...

A character list/vector. If length(...) is 2 and align is not 'split', values are pasted together.

align

Text alignment in document. Options are 'center', 'left', 'right', and 'split'. A 'split' alignment will left align the string in the first text item and right align the second. Defaults to center.

bold

TRUE or FALSE. Defaults to FALSE.

italic

TRUE or FALSE. Defaults to FALSE.

font

A string to specify the font display. Ensure the intended RTF reader can display the selected font. Fonts for all fields will default to the default font of the rtf_doc object, which unless otherwise assigned, is Courier New.

font_size

Font size in points. Font sizes for all fields will default to the default font size of the rtf_doc object, which unless otherwise assigned, is 12

index

Position to display header or footnote lines in the RTF document. Orders in ascending order with NAs last. Defaults to NA.

Value

An object of class hf_line with the properties described in the Arguments section.

Supported Formatting

Several special display formats are supported to display document data. When the rtf_doc is written, the package will determine if the text of an hf_line object starts with a keyword. Regular expression matching and replacement is used for formatting.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Adding lines during rtf_doc construction
ht <- huxtable::huxtable(
 column1 = 1:5,
 column2 = letters[1:5]
)
titles_l <- list(
  hf_line(c("The Title Left", "The Titles Right"), align = "split"),
  hf_line("A Bold, italic Title", bold = TRUE, italic = TRUE,
    align = "left", font_size = 20, font = "Times New Roman")
)
rtf <- rtf_doc(ht, titles = titles_l)

# Adding lines after rtf_doc construction
rtf <- add_footnotes(rtf,
    hf_line("PAGE_FORMAT: Page %s of %s"),
    hf_line("DATE_FORMAT: %H:%M %A, %B %d, %Y"),
    hf_line("FILE_PATH: Source: %s")
  )

pharmaRTF documentation built on Sept. 28, 2021, 5:08 p.m.