officer (version 0.2.1)

body_end_section: add section

Description

add a section in a Word document. A section affects preceding paragraphs or tables.

Usage

body_end_section(x, landscape = FALSE, colwidths = c(1), space = 0.05,
  sep = FALSE, continuous = FALSE)

body_default_section(x, landscape = FALSE)

break_column_before(x)

Arguments

x

an rdocx object

landscape

landscape orientation

colwidths

columns widths as percentages, summing to 1. If 3 values, 3 columns will be produced.

space

space in percent between columns.

sep

if TRUE a line is separating columns.

continuous

TRUE for a continuous section break.

Details

A section starts at the end of the previous section (or the beginning of the document if no preceding section exists), and stops where the section is declared. The function body_end_section() is reflecting that Word concept. The function body_default_section() is only modifying the default section of the document.

Examples

Run this code
# NOT RUN {
library(magrittr)

str1 <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " %>%
  rep(10) %>% paste(collapse = "")

my_doc <- read_docx() %>%
  # add a paragraph
  body_add_par(value = str1, style = "Normal") %>%
  # add a continuous section
  body_end_section(continuous = TRUE) %>%
  body_add_par(value = str1, style = "Normal") %>%
  body_add_par(value = str1, style = "Normal") %>%
  # preceding paragraph is on a new column
  break_column_before() %>%
  # add a two columns continous section
  body_end_section(colwidths = c(.6, .4),
                   space = .05, sep = FALSE, continuous = TRUE) %>%
  body_add_par(value = str1, style = "Normal") %>%
  # add a continuous section ... so far there is no break page
  body_end_section(continuous = TRUE) %>%
  body_add_par(value = str1, style = "Normal") %>%
  body_default_section(landscape = TRUE)

print(my_doc, target = "section.docx")
# }

Run the code above in your browser using DataCamp Workspace