When converting rmarkdown into PDF, is it possible to determine the position (on the page) and the size of the chart very precisely according to my needs?
Asked
Active
Viewed 194 times
0
-
Have a look here https://stackoverflow.com/questions/29696172/how-to-hold-figure-position-with-figure-caption-in-pdf-output-of-knitr – Julian Aug 25 '22 at 07:41
-
1Not really, latex is notorious in this regard. – r2evans Aug 25 '22 at 08:20
1 Answers
0
Using the Pagedown package you can position elements as you need.
When you put in a figure using an R code chunk, you can give it a caption like so:
```{r, example-label, echo=FALSE, message=FALSE, warning=FALSE, fig.cap="Example Chart"}
ggplot whatever
```
When you knit the document it'll then output your plot as a figure, which will be in a html img tag. The caption from the code chunk will then be assigned as the alt property of the img.
Then you can target the image using CSS. For example:
img[alt="Example Chart"] {
display: none;
}
Alternatively, you could simply put in an image using markdown and then give it a style, like so:
{class="" style="display: block; margin-left: auto; margin-right: auto; width:50%;"}
In short, Pagedown can give you the ability to position and size charts as you want, if you're comfortable with CSS and/or HTML.

thoughthollow
- 16
- 4