1

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?

1
  • does indenting by two additional spaces the fig_width and fig_height values help?
    – Fred Boehm
    Apr 2, 2018 at 2:37

1 Answer 1

1

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.