as.caption: Create caption

View source: R/caption.R

as.captionR Documentation

Create caption

Description

Create caption

Usage

as.caption(
  x,
  short = NULL,
  short_repeat = TRUE,
  short_sep = NULL,
  write = FALSE
)

Arguments

x

caption text.

short

an abbreviated form of the caption to be used in a list of tables.

short_repeat

logical; if a short caption is provided, it will be repeated at the start of the main caption.

short_sep

a character sequence used to separate the short title with the main caption when a short title is specified.

write

logical; if TRUE, caption will be written to output file when stable_save() is called; this argument does not apply to stable_long objects whose captions are always written to output the output file.

Details

Caption text (in x) can contain a short caption title enclosed in brackets (⁠[]⁠) as the opening characters (see examples). The short title is assumed to start after the opening [ and end prior to ⁠]⁠ when all brackets are matched, allowing ⁠[...]⁠ in the short title as long as all brackets are matched. For other scenarios where a single ⁠]⁠ may need to appear in the short title, the user should use the short argument instead of the bracket notation.

Value

An object inheriting from st_caption and character.

Examples


# No separate short title
as.caption("Main title text")

# Note that the short title is repeated by default
as.caption("[Short title]. Main title text")

unclass(as.caption("[Short title]. Main title text."))
unclass(as.caption(". Main title text.", short = "Short"))


metrumresearchgroup/pmtables documentation built on Oct. 27, 2024, 5:16 p.m.