Last chance! 50% off unlimited learning
Sale ends in
The function lets you add or replace a Word paragraph style.
docx_set_paragraph_style(
x,
style_id,
style_name,
base_on = "Normal",
fp_p = fp_par(),
fp_t = NULL
)
an rdocx object
a unique style identifier for Word.
a unique label associated with the style identifier. This label is the name of the style when Word edit the document.
the style name used as base style
paragraph formatting properties, see fp_par()
.
default text formatting properties. This is used as
text formatting properties, see fp_text()
. If NULL (default), the
paragraph will used the default text formatting properties (defined by
the base_on
argument).
library(officer)
doc <- read_docx()
doc <- docx_set_paragraph_style(
doc,
style_id = "rightaligned",
style_name = "Explicit label",
fp_p = fp_par(text.align = "right", padding = 20),
fp_t = fp_text_lite(
bold = TRUE,
shading.color = "#FD34F0",
color = "white")
)
doc <- body_add_par(doc,
value = "This is a test",
style = "Explicit label")
docx_file <- print(doc, target = tempfile(fileext = ".docx"))
docx_file
Run the code above in your browser using DataLab