officer support

library(officedown)
library(officer)

Introduction

Package {officer} provides functions to produce document blocks and runs elements. They can be used in the R Markdown document to produce elements with formatting not available by default with R Markdown and pandoc:

Features

---
author: 'Bruce'
date: '0189-12-27'
output: 
  officedown::rdocx_document:
      mapstyles:
        Normal: ['First Paragraph', 'Author', 'Date']
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(officedown)
library(officer)
fp <- fp_par(text.align = "center", padding.top = 120)
ft <- fp_text(font.size = 12, bold = TRUE, color = "#C32900", font.family = "Cambria")
```

## Chunk outputs

The package `r ftext("officedown", ft)` is great. 

This is a Word field, the file size is `r run_seqfield("FILESIZE \\k \\* MERGEFORMAT")` Kb. 

## Paragraph settings

This text is centered `r fp_par(text.align = "center")`.

## Section definitions

<!---BLOCK_MULTICOL_START--->

This text is on column 1. This text is on column 1.
This text is on column 1. This text is on column 1.
This text is on column 1. This text is on column 1.
This text is on column 1. This text is on column 1.
This text is on column 1. This text is on column 1.`r fp_par(text.align = "justify")`
`r run_columnbreak()`

This text is on column 2.
This text is on column 2.
This text is on column 2.
This text is on column 2.
This text is on column 2.
This text is on column 2.`r fp_par(text.align = "justify")`

<!---BLOCK_MULTICOL_STOP{widths: [3,3], space: 0.2, sep: true}--->


<!---BLOCK_LANDSCAPE_START--->

This is a landscape section.`r fp`

<!---BLOCK_LANDSCAPE_STOP--->


This is a custom section using `block_section`.`r fp`

```{r}
ps <- prop_section(
  page_margins = page_mar(bottom = 1, top = 2, left = 1.5),
  type = "oddPage"
)
block_section(ps)
```

We are back on default section.`r fp`

Tags

Tags (as HTML comments) have been designed to be less verbose and easier to use; for landscape pages, for multi-columns sections and for tables of contents.

The following will be transformed as a table of content:

<!---BLOCK_TOC--->

And the following will pour the content of an external docx file into the produced document:

<!---BLOCK_POUR_DOCX{docx_file: 'path/to/docx'}--->

The parameters are defined in a yaml string. Each item in the list is a list of key/value pairs defined with key: value form (the colon must be followed by a space).

Sections blocks

Section blocks need to be used in pairs:

landscape orientation

Tag name R function Has args
BLOCK_LANDSCAPE_START block_section_continuous no
BLOCK_LANDSCAPE_STOP block_section_landscape no
The following will be in a separated section with landscape orientation

<!---BLOCK_LANDSCAPE_START--->

Blah blah blah.

<!---BLOCK_LANDSCAPE_STOP--->

section with columns

Tag name R function Has args
BLOCK_MULTICOL_START block_section_continuous no
BLOCK_MULTICOL_STOP block_section_columns yes
The following will be in a separated section with 2 columns:

<!---BLOCK_MULTICOL_START--->

Blah blah blah on column 1.

<!---CHUNK_COLUMNBREAK--->
Blah blah blah on column 2.


<!---BLOCK_MULTICOL_STOP{widths: [3,3], space: 0.2, sep: true}--->

Illustrations

Caption from scratch