 <p>you'll probably find it easier to query sizes if you work with the gtable,</p> <pre><code>--- title: "Untitled" header-includes: - \usepackage{lipsum} output: pdf_document: fig_caption: yes fig_crop: no keep_tex: yes geometry: width=5in --- ```{r setup, include=FALSE} library(ggplot2) library(dplyr) library(grid) library(knitr) general_fig_width &lt;- 5 ``` ```{r plot, fig.show=FALSE} p &lt;- diamonds %&gt;% sample_frac(0.3) %&gt;% ggplot(aes(x = carat, y = price, color = price)) + geom_point() + theme_dark() + theme(plot.margin = unit(c(0,0,0,0), "pt")) g &lt;- ggplotGrob(p) if(getRversion() &lt; "3.3.0"){ g$widths &lt;- grid:::unit.list(g$widths) g$widths[4] &lt;- list(unit(general_fig_width, "in")) } else { g$widths[4] &lt;- unit(general_fig_width, "in") } fig_width &lt;- convertWidth(sum(g$widths), "in", valueOnly = TRUE) left_width &lt;- convertWidth(sum(g$widths[1:3]), "in", valueOnly = TRUE) ggsave('plot-tmp.pdf', width=fig_width, height=2) ``` \begin{figure}[!hb] \hspace{`r -left_width`in}\includegraphics[width=`r fig_width`in]{plot-tmp} \end{figure} \lipsum[2] </code></pre> <p><a href="https://i.stack.imgur.com/jplWa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jplWa.png" alt="enter image description here"></a></p>