Can't override device size in pdf output

My latest project is about scanning an old book in German Fraktur typeface and putting the scanned page, Tesseract OCR text and English Google translation side-by-side. Humans can then easily correct the robots work.

How can I get precise control over location, size and scaling of mixed images, plots and tables in a PDF document? Banging my head against the wall. I want to display an image next to two tables and scale all three of those objects to fit a landscape pdf page. No matter what I try I can't seem to get the objects to scale AND fill up the page. It seems that the default graphics device size is constraining the output and I can't figure out how to override that. Here is an illustrative reprex (although I've tried many permuations of YAML headers, chunk headers, LaTex code and multipanelfigure parameters). This code produces a figure that crops the constituent elements and occupies only the upper right quadrant of the page. Thanks for any help.

---
output: pdf_document
classoption: landscape     
---


```{r sample, message=FALSE, warning=FALSE, include=FALSE}
library(knitr)
library(grid)
library(gridExtra)
library(magick)
library(multipanelfigure)

one_line <- "Here is some rando text that is 40 lines about 80 columns. See what I did there?"
df <- data.frame(text=rep(one_line,40))
img <- "https://jeroen.github.io/images/frink.png"
# instantiate
figure <- multi_panel_figure(
   columns = 4,
   rows = 1)

figure <- figure %>%
   fill_panel(panel = img,scaling = "stretch",column = c(1,2)) %>%
   fill_panel(tableGrob(df, theme = ttheme_default(base_size = 7)),
              row= 1,column = 3,panel_clip = "off") %>%
   fill_panel(tableGrob(df, theme = ttheme_default(base_size = 7), rows = NULL),
              row= 1,column = 4,panel_clip = "off")

figure

Maybe this (setting figure dimensions) helps

---
output: 
  pdf_document:
    keep_tex: true
classoption: landscape     
---


```{r setup, message=FALSE, warning=FALSE,include=F}
library(knitr)
library(grid)
library(gridExtra)
library(magick)
library(multipanelfigure)
```

```{r sample}
one_line <- "Here is some rando text that is 40 lines about 80 columns. See what I did there?"
df <- data.frame(text=rep(one_line,40))
img <- "https://jeroen.github.io/images/frink.png"
```

# use columns
```{r plot_it1, fig.width=16, fig.height=8}
# instantiate

figure <- multi_panel_figure(
   columns = 4,
   rows = 1)

figure

figure <- figure %>%
   fill_panel(panel = img,scaling = "stretch",row=1,column = 1:2) %>%
   fill_panel(tableGrob(df, theme = ttheme_default(base_size = 7)),
              row= 1,column = 3,panel_clip = "off") %>%
   fill_panel(tableGrob(df, theme = ttheme_default(base_size = 7), rows = NULL),
              row= 1,column = 4,panel_clip = "off")
figure
```

Thanks I had tried that but I was using fig.width in the YAML section and the multi-panel-figure function call as well which didn't play well with the chunk options. I also found that adjusting the table cell size is possible in tableGrob(theme=ttheme_default()) which let me squish the rows down to fit on the page.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.