I'm using RStudio version 1.4.1717 on a Windows 10 system.
When I use the code below, working within an rmd file, to render a plot in RStudio it appears fine. But when I knit the rmd file (in this case into a Word docx, though I've encountered the same issue knitting it into pdf) by simply clicking Knit within RStudio, the text in the title is cut off. (The caption fits in both versions of the plot, but in the past I've had the same issue with that too, as well as with legends being cut off.) Compare the two images below.
Plot rendered when rmd knitted from RStudio to word docx
I could iteratively adjust the title text size in order to make sure it is not cut off when knitted, but since I actually have dozens of figures and a very large rmd file (for a ~40 page masters thesis) it would be very time consuming to fix this 'manually' for each figure.
Does anyone know why this issue is happening, and what I might be able to do so that the plot that is in the knitted document is exactly the same as the plot rendered within RStudio?
Thank you!
```
---
title: "temp"
output: word_document
---
```{r data and scatter plot, echo=FALSE}
library(ggplot2)
library(dplyr)
df <- data.frame(c("a",1),
c("b",5),
c("c",2),
c("d",3),
c("e",6),
c("f",10)) %>%
data.table::transpose() %>% mutate(V2 = as.numeric(V2))
ggplot(df, aes(x=V1, y=V2)) +
geom_point() +
guides(fill = guide_legend(title = "Industry")) +
xlab("Made up labels") +
ylab("Made up data") +
labs(title = "Made up title that fits when this is created within RStudio with zero problems",
caption = "Made up caption that fits when this is created within RStudio")
```