as_paragraph: Build a paragraph from chunks

View source: R/05_content.R

as_paragraphR Documentation

Build a paragraph from chunks

Description

as_paragraph() assembles one or more chunks into a single paragraph that defines the content of a flextable cell. Each cell in a flextable contains exactly one paragraph; a paragraph is an ordered sequence of chunks.

Chunks are the smallest content units and can be created with as_chunk() (formatted text), as_b() / as_i() (bold / italic shortcuts), minibar() (inline bar), as_image() (image), gg_chunk() (ggplot), as_equation() (equation) or hyperlink_text() (link). Plain character strings passed to as_paragraph() are automatically converted to chunks via as_chunk().

The resulting paragraph is passed to the value argument of compose(), mk_par(), add_header_lines(), add_footer_lines() or footnote() to set cell content.

Usage

as_paragraph(..., list_values = NULL)

Arguments

...

chunk elements that are defining the paragraph content. If a character is used, it is transformed to a chunk object with function as_chunk().

list_values

a list of chunk elements that are defining the paragraph content. If specified argument ... is unused.

See Also

as_chunk(), minibar(), as_image(), hyperlink_text()

Other functions to compose cell content: append_chunks(), compose(), footnote(), labelizor(), prepend_chunks(), void()

Examples

library(flextable)
ft <- flextable(airquality[sample.int(150, size = 10), ])
ft <- compose(ft,
  j = "Wind",
  value = as_paragraph(
    as_chunk(Wind, props = fp_text_default(color = "orange")),
    " ",
    minibar(value = Wind, max = max(airquality$Wind), barcol = "orange", bg = "black", height = .15)
  ),
  part = "body"
)
ft <- autofit(ft)
ft

flextable documentation built on June 2, 2026, 9:08 a.m.