Adrian
Adrian

Reputation: 9803

R: knitr graphic gets cutoff in .docx output

I am having trouble adjusting the dimensions of my figure in R markdown so that the outputted knitr figure fits to the page on a word document (my figure is too wide, so it gets cut off).

I've tried playing around with the height and width and even using a reference_docx where I adjusted the margins, but nothing seems to work. I think changing the fig_width and fig_height did absolutely nothing to the output. I literally tried setting both width and height to 0, and the same figures show up.

---
output:
  word_document:
  fig_width: 12
  fig_height: 5
  reference_docx: margins.docx
---

I can't provide a reproducible example, but does anyone know what other knitr options I can play around with to adjust my figure dimensions/aspect ratio?

Upvotes: 1

Views: 1213

Answers (1)

Fred Boehm
Fred Boehm

Reputation: 668

Using yaml header:

---
output:
  word_document:
    fig_width: 2
    fig_height: 5
---

where I position fig_height and fig_width to start beneath the r in word_document, worked for me. If you align your yaml header like this, do you get what you want?

Upvotes: 1

Related Questions