officer: Insert section break with landscape format in .rmd-file

873 Views Asked by At

I want to include a wide flextable into a word document so it appears on a landscape page.

The officeverse-guidebook (https://ardata-fr.github.io/officeverse/index.html) includes examples on how to add formatted paragraphs or a table in a Rmarkdown. Whereas, it lacks an example on how to address a change in paper format from portrait to landscape and back again in combination with a table or graphic.

I have tried the method

# Appendix
## Timing

<!---BLOCK_LANDSCAPE_START--->

```{r, include=T}
tibble("Age of inclusion" = c("13 - 28"," ","20 - 28","22 - 28","24 - 28","26 - 28","28"),
      "1" = c("Graffities","Purse snatching","Driving w/o permit","Illegal\nemployment","Ill. advantage\nover employer","False claims\n(insurance)","Paying for\nservice w/o bill"),
      "2" = c("Scratching","Robbery","Hit and run","Drunk driving","Ill. advantage\nfor employer","False claims\n(public agency)","Illicit upload of\nproprietary media"),
      "3" = c("Vandalism","Burglary","Partner violence"," "," ","Tax evasion"," "),
      "4" = c("Machine theft","Other thefts"," "," "," ","False\nrepresentation\n(sale of goods)"," "),
      "5" = c("Shoplifting","Accepting\nstolen goods"," "," "," ","Selling goods w/o\nintent to deliver"," "),
      "6" = c("Bicycle theft","Aggrav. assault\nw/o a weapon"," "," "," ","Fraudul.\ninducement\nto contract"," "),
      "7" = c("Motor-vehicle\ntheft","Aggrav. assault\nwith a weapon"," "," "," "," "," "),
      "8" = c("Theft out of vehicle","Drug dealing"," "," "," "," "," ")) %>%
flextable %>% 
flextable::align(j=1, align = "left", part = "all") %>% 
bold(j = 1, bold = T) %>%
bold(i = 1, bold = T, part = "header") %>%
set_caption(table_nums("timing")) %>%
fit_to_width(max_width = 6.5, max_iter = 2)
```

<!---BLOCK_LANDSCAPE_end--->

Lorem ipsum …

without avail.

Any help would be appreciated.

Best, Georg

1

There are 1 best solutions below

0
On

here is an example:

---
date: "`r Sys.Date()`"
author: "Your Name"
title: "officedown template"
output: 
  officedown::rdocx_document:
    mapstyles:
      Normal: ['First Paragraph']
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, fig.cap = TRUE)
library(officedown)
library(officer)
library(flextable)
op_section <- prop_section(type = "continuous")
close_section <- prop_section(
    page_size = page_size(orient = "landscape"), 
    type = "continuous")
```

```{r}
block_section(op_section)
```

```{r}
qflextable(head(mtcars))
```

```{r}
block_section(close_section)
```

enter image description here

You can read more about blocks here:

https://ardata-fr.github.io/officeverse/officedown-for-word.html#add-blocks