Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use raster graphics #14

Open
doabell opened this issue Jul 7, 2023 · 0 comments
Open

Use raster graphics #14

doabell opened this issue Jul 7, 2023 · 0 comments

Comments

@doabell
Copy link
Contributor

doabell commented Jul 7, 2023

Currently the generated report embeds PDF figures under results/figures, like this one.
These figures are stored in a vector format, meaning the report can take minutes to load and print.

The solution is to change the graphics device to png in the chunk options on Line 127; this outputs PNGs to results/figures.
To make the images clear enough, fig.retina is also needed. Somewhere between 3 and 6 should be good for print quality.

knitr::opts_chunk$set(
  dev = "png",
  fig.retina = 4
)

Note: the $\LaTeX$ syntax for including an image is \includegraphics{image}, without file extensions.
Therefore, for the final report to use raster PNGs and not PDFs, one will need to delete the PDF figures first.

Alternatively, one can include a raw $\LaTeX$ code block inside the R markdown to specify which extensions to look for first:

```{=latex}
\DeclareGraphicsExtensions{%
    .png,.PNG,%
    .pdf,.PDF,%
    .jpg,.jpeg}
```

See also knitr: Saving graphs in both pdf and png format but using pdf files in the final document - Stack Overflow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant