Skip to contents

A section with multiple columns is added to the document.

You may prefer to use body_end_block_section() that is more flexible.

Usage

body_end_section_columns(x, widths = c(2.5, 2.5), space = 0.25, sep = FALSE)

Arguments

x

an rdocx object

widths

columns widths in inches. If 3 values, 3 columns will be produced.

space

space in inches between columns.

sep

if TRUE a line is separating columns.

Section breaks occupy a line

Ending a section is materialized in the document by an empty paragraph mark holding the section properties; this is how the OOXML format represents a section break, there is no other way, and Word does the same when a section break is inserted manually. As any paragraph mark, it occupies one line whose height depends on the default paragraph style. The same applies to run_columnbreak() when it has to be placed after a table: a table cannot host the break, so it must live in a paragraph that also takes one line. If that residual line matters for your layout, define a dedicated paragraph style with a very small font size (e.g. 1pt) and no spacing in your Word template, and use it for the paragraph hosting the break: fpar(run_columnbreak(), fp_p = fp_par(word_style = "MyTinyStyle")).

Examples

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

doc_1 <- read_docx()
doc_1 <- body_add_par(doc_1, value = str1, style = "Normal")
doc_1 <- body_add_par(doc_1, value = str1, style = "Normal")
doc_1 <- body_end_section_columns(doc_1)
doc_1 <- body_add_par(doc_1, value = str1, style = "Normal")
print(doc_1, target = tempfile(fileext = ".docx"))