Skip to content

Commit

Permalink
fix: longtable, avoid duplicated caption entries
Browse files Browse the repository at this point in the history
fix #534
  • Loading branch information
davidgohel committed May 5, 2023
1 parent cb72fb6 commit c3e3459
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: flextable
Type: Package
Title: Functions for Tabular Reporting
Version: 0.9.2.003
Version: 0.9.2.004
Authors@R: c(
person("David", "Gohel", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ This property is used in HTML or LaTeX deps resolution to know
when to be recursive
- `dim_pretty()` returns correct numbers when not 'inches'
- `as_flextable.table()` now propagates `...` as expected
- when table was on two pages, there were duplicated caption entries,
this is fixed thanks to Christophe Dervieux and Nick Bart.

# flextable 0.9.1

Expand Down
10 changes: 9 additions & 1 deletion R/latex_str.R
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ augment_part_separators <- function(z, no_container = TRUE) {
merge(z[, list(ft_row_id = max(.SD$ft_row_id)), by = "part"],
data.frame(
part = factor(c("header", "body", "footer"), levels = c("header", "body", "footer")),
part_sep = if(no_container) c("\\endhead", "", "\\endfoot") else c("\\endhead", "", ""),
part_sep = if(no_container) c("\\endfirsthead", "", "\\endfoot") else c("\\endfirsthead", "", ""),
stringsAsFactors = FALSE
),
by = c("part")
Expand All @@ -327,6 +327,14 @@ augment_part_separators <- function(z, no_container = TRUE) {
setorderv(part_separators, c("part", "ft_row_id"))

z <- merge(z, part_separators, by = c("part", "ft_row_id"))

if ("header" %in% z$part) {
z_header <- z[z$part %in% "header",]
z_header$ft_row_id <- z_header$ft_row_id + max(z_header$ft_row_id)
z_header$part_sep <- "\\endhead"
z <- rbind(z[z$part %in% "header",], z_header, z[!z$part %in% "header",])
}

z
}

Expand Down

0 comments on commit c3e3459

Please sign in to comment.