officer (version 0.3.0)

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, margins = c(top = NA, bottom = NA,
  left = NA, right = NA), colwidths = c(1), space = 0.05, sep = FALSE,
  continuous = FALSE)

body_default_section(x, landscape = FALSE, margins = c(top = NA, bottom = NA, left = NA, right = NA))

Arguments

x

an rdocx object

landscape

landscape orientation

margins

a named vector of margin settings in inches, margins not set remain at their default setting

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
  slip_in_column_break(pos = "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, margins = c(top = 0.5, bottom = 0.5))

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

Run the code above in your browser using DataCamp Workspace