Unable to produce landscape orientation microsoft word document from R markdown when using classoption: landscape
Asked Answered
I

1

6

I am unable to produce a landscape orientation document when using RStudio and Rmarkdown.

R is version 3.4.2 RStudio is version 0.98.1103

I cannot change these as they are the latest versions on the cluster which I run my programs on.

After knitting the document, I do get a document out (in portrait form), however get the following error message:

Output created: test_landscape.docx
Warning message:
In (function (toc = FALSE, toc_depth = 3, fig_width = 5, fig_height = 4,  :
  table of contents for word_document requires pandoc >= 1.14

Reproducible code is here:

---
title: "test_landscape"
author: "Name"
date: "09/10/2018"
output: word_document
classoption: landscape
---

Test for landscape orientation

```{r}
summary(cars)
```

You can also embed plots, for example:

```{r, echo=FALSE}
plot(cars)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

Unsure if this is more suited to cross validated, as R is a statistical programming language, but the question is not a statistical one.

Thank you.

EDIT: Have edited title to better represent my problem after the below comment.

Injun answered 9/10, 2018 at 11:7 Comment(1)
classoption is used for PDF output via LaTeX. I guess you have to use a different template for Word output in landscape format.Packston
I
6

Thanks to Ralf Stubner.

There is a good explanation for the process of how to do this specifically for word here: https://rmarkdown.rstudio.com/articles_docx.html

You must create a word document that has the setting (e.g. landscape orientation) that you want, save it in the same location as your .Rmd file and then refer to it as the reference document, e.g.:

---
title: "test_landscape"
author: "Name"
date: "09/10/2018"
output: 
  word_document:
    reference_docx: word_styles.docx
---
Injun answered 9/10, 2018 at 13:41 Comment(1)
This is a powerful solution that has a LOT of advantages, but also a lot of possible, unpredictable badness because of Word. I'll point out that the header seems to require newlines and indents to be interpreted correctly by YAML, at least when I explore this option.Shows

© 2022 - 2024 — McMap. All rights reserved.