officer (version 0.1.4)

body_end_section: add section

Description

add a section in a Word document. A section is attached to the latest paragraph of the section.

Usage

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

Arguments

x

an rdocx object

landscape

landscape orientation

colwidths

columns widths in percent, if 3 values, 3 columns will be produced. Sum of this argument should be 1.

space

space in percent between columns.

sep

if TRUE a line is sperating columns.

Details

A section start at the end of the previous section (or the beginning of the document if no preceding section exists), it stops where the section is declared. The function is reflecting that (complicated) Word concept, by adding an ending section attached to the paragraph where cursor is.

Examples

Run this code
# NOT RUN {
library(officer)
library(magrittr)

str1 <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " %>%
  rep(20) %>% paste(collapse = "")
str2 <- "Sed hendrerit, est eget convallis vestibulum, mauris ligula. " %>%
  rep(20) %>% paste(collapse = "")
str3 <- "Aenean venenatis varius elit et fermentum vivamus vehicula. " %>%
  rep(20) %>% paste(collapse = "")

my_doc <- read_docx()  %>%
  body_add_par("String 1", style = "heading 1") %>%
  body_add_par(value = str1, style = "Normal") %>%
  body_add_par("String 2", style = "heading 1") %>%
  body_add_par(value = str2, style = "Normal") %>%
  body_end_section(landscape = TRUE, colwidths = c(.6, .4), space = .05, sep = FALSE) %>%
  body_add_par("String 3", style = "heading 1") %>%
  body_add_par(value = str3, style = "Normal")

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

Run the code above in your browser using DataLab