From 0db25d1b13a5c8f4b07ab9e09d6004fb121af938 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Mon, 23 Mar 2026 07:12:57 -0400 Subject: [PATCH 1/2] Update flextable vignette pagination example with actual pagination Replace the eval=FALSE short-table example with a 60-row table that forces pagination, showing preview of page 1 and page 2 inline so readers can see how headers repeat and content flows across pages. Co-Authored-By: Claude Opus 4.6 --- vignettes/v07-flextable.Rmd | 56 +++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/vignettes/v07-flextable.Rmd b/vignettes/v07-flextable.Rmd index 77cef1a..9eb48b2 100644 --- a/vignettes/v07-flextable.Rmd +++ b/vignettes/v07-flextable.Rmd @@ -147,24 +147,64 @@ export_tfl( When a flextable table is too tall to fit on a single page, `export_tfl()` splits it across pages by subsetting body rows. The header is repeated on -each page. +each page, and caption and footnote are carried through to every page. + +Here we build a 60-row table that is too tall for a single landscape page. +Using `preview = c(1, 2)` renders the first two pages side by side so you can +see how the header repeats and content flows across pages. + +```{r pagination-data} +# Build a data set large enough to force pagination +big_data <- data.frame( + ID = seq_len(60), + Name = paste("Subject", seq_len(60)), + Age = sample(25:75, 60, replace = TRUE), + Weight = round(rnorm(60, 70, 12), 1), + Score = round(runif(60, 50, 100), 1), + Group = rep(c("Treatment", "Control"), each = 30) +) + +big_ft <- flextable(big_data) |> + set_caption("Table 5. Subject Listing — Full Cohort") |> + add_footer_lines("Source: Simulated clinical trial data.") |> + theme_booktabs() +``` -```{r pagination, eval = FALSE} -big_ft <- flextable(mtcars[, 1:6]) |> - set_caption("All Motor Trend Cars") |> - add_footer_lines("Source: datasets package.") +**Page 1:** +```{r pagination-page1, fig.width = 11, fig.height = 8.5, out.width = "100%"} export_tfl( big_ft, - file = "paginated.pdf", + preview = 1, header_left = "Analysis Report", header_rule = TRUE, footer_rule = TRUE ) ``` -Each page carries the same caption and footnote from the original -flextable object. +**Page 2:** + +```{r pagination-page2, fig.width = 11, fig.height = 8.5, out.width = "100%"} +export_tfl( + big_ft, + preview = 2, + header_left = "Analysis Report", + header_rule = TRUE, + footer_rule = TRUE +) +``` + +To write all pages to a PDF file instead: + +```{r pagination-pdf, eval = FALSE} +export_tfl( + big_ft, + file = "paginated.pdf", + header_left = "Analysis Report", + header_rule = TRUE, + footer_rule = TRUE +) +``` **Note:** When pagination occurs, per-cell formatting applied via `color()`, `bg()`, `bold()`, etc. is not preserved on paginated pages. From 6ea687aba8252f7b908ce54960306f01225679f8 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Mon, 23 Mar 2026 07:18:39 -0400 Subject: [PATCH 2/2] Update flextable vignette pagination example with actual pagination Replace the eval=FALSE short-table example with a 60-row table that forces pagination, previewing the first two pages inline so readers can see how headers repeat and content flows across pages. Co-Authored-By: Claude Opus 4.6 --- vignettes/v07-flextable.Rmd | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/vignettes/v07-flextable.Rmd b/vignettes/v07-flextable.Rmd index 9eb48b2..e5bca8f 100644 --- a/vignettes/v07-flextable.Rmd +++ b/vignettes/v07-flextable.Rmd @@ -149,12 +149,7 @@ When a flextable table is too tall to fit on a single page, `export_tfl()` splits it across pages by subsetting body rows. The header is repeated on each page, and caption and footnote are carried through to every page. -Here we build a 60-row table that is too tall for a single landscape page. -Using `preview = c(1, 2)` renders the first two pages side by side so you can -see how the header repeats and content flows across pages. - -```{r pagination-data} -# Build a data set large enough to force pagination +```{r pagination, fig.width = 11, fig.height = 8.5, out.width = "100%"} big_data <- data.frame( ID = seq_len(60), Name = paste("Subject", seq_len(60)), @@ -168,38 +163,10 @@ big_ft <- flextable(big_data) |> set_caption("Table 5. Subject Listing — Full Cohort") |> add_footer_lines("Source: Simulated clinical trial data.") |> theme_booktabs() -``` - -**Page 1:** - -```{r pagination-page1, fig.width = 11, fig.height = 8.5, out.width = "100%"} -export_tfl( - big_ft, - preview = 1, - header_left = "Analysis Report", - header_rule = TRUE, - footer_rule = TRUE -) -``` - -**Page 2:** - -```{r pagination-page2, fig.width = 11, fig.height = 8.5, out.width = "100%"} -export_tfl( - big_ft, - preview = 2, - header_left = "Analysis Report", - header_rule = TRUE, - footer_rule = TRUE -) -``` - -To write all pages to a PDF file instead: -```{r pagination-pdf, eval = FALSE} export_tfl( big_ft, - file = "paginated.pdf", + preview = 1:2, header_left = "Analysis Report", header_rule = TRUE, footer_rule = TRUE