Skip to content

clementinejager/officedown

 
 

Repository files navigation

Travis build status AppVeyor build status lifecycle CRAN status

officedown is bringing some officer features into R markdown documents.

  1. Pimp your R markdown documents… to produce Word documents.

The package is to be used when you want to use R Markdown documents to produce Microsoft Word documents but also want options for landscape orientation, with narrow margins, with formatted text, when some paragraphs have to be centered.

  1. Add vector graphics into your PowerPoint document. This feature let’s you add rvg in you presentation.

Usage

use RStudio Menu to create a document from officedown template.

It will create an R markdown document, parameter output is to be set to officedown::rdocx_document. Also package officedown need to be loaded.

---
date: "2019-11-12"
author: "David Gohel"
title: "Document title"
output: 
  officedown::rdocx_document
---


```r
library(officedown)
#> Warning: S3 method 'print.dml' was declared in NAMESPACE but not found
```

Tags have been made to make less verbose and easier use. Some are expected parameters (i.e. CHUNK_TEXT, BLOCK_MULTICOL_STOP). These parameters need to be defined as inline yaml.

Chunks

Chunks are to be used in a paragraph in an R markdown document.

Output type Tag name R function Has args
chunk CHUNK_PAGEBREAK chunk_page_break no
chunk CHUNK_TEXT chunk_styled_text yes
chunk CHUNK_TEXT_STYLE chunk_text_stylenamed yes
chunk CHUNK_COLUMNBREAK chunk_column_break no
chunk add_paragraph_settings yes
This text will be followed by a break page.<!---CHUNK_PAGEBREAK--->

`r add_paragraph_settings(align='center', paddings = list(t= 120, b= 20))`
This paragraph will be centered and wil have a 120 pts top padding and 20 bottom padding.
Text can be styles: <!---CHUNK_TEXT{str: 'officedown', color: 'orange'}---> is really cool.

Blocks

Blocks are to be used as a paragraph in an R markdown document.

Output type Tag name R function Has args
block BLOCK_TOC block_toc yes
block BLOCK_POUR_DOCX block_pour_docx yes
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'}--->

Sections blocks

Section blocks are also blocks but they 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}--->

Working with officedown

Installation

You can install officedown from github with:

# install.packages("devtools")
devtools::install_github("davidgohel/officedown")

Supported formats require some minimum pandoc versions:

R Markdown output pandoc version comment
Microsoft Word >= 2.0 require a recent RStudio (> june 2018)
Microsoft PowerPoint >= 2.4 require pandoc installation

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • R 100.0%