Skip to content

Commit 723e78a

Browse files
authored
Merge pull request #262 from Crunch-io/INNOV-498-joe
Fixes regression with pagebreak_in_banner
2 parents 35963db + 3a4005d commit 723e78a

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Description: In order to generate custom survey reports, this package provides
66
'banners' (cross-tabulations) and codebooks of datasets in the Crunch
77
(<https://crunch.io/>) web service. Reports can be written in 'PDF' format
88
using 'LaTeX' or in Microsoft Excel '.xlsx' files.
9-
Version: 1.4.3
9+
Version: 1.4.4
1010
Authors@R: c(
1111
person("Persephone", "Tsebelis", role="aut"),
1212
person("Kamil", "Sedrowicz", role="aut"),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## crunchtabs 1.4.4
2+
3+
- Fixes a regression where absolutelynopagebreak was duplicated or not functional in some situations. (pagebreak_in_banner=TRUE and one_per_page=FALSE)
4+
15
## crunchtabs 1.4.3
26

37
- categorical_arrays were previously spliced into the first position at every question iteration, leading to questions being presented out of vector order in the resulting pdf output. This update patches the results list back together when splicing the array questions in-place. Now, the order of variables is the same as the order presented in the output pdf. (INNOV-498)

R/tex-table.R

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ latexTableBody <- function(df, theme, question_alias = NULL) {
195195
rows <- apply(cbind(rownames(dt), dt), 1, paste, collapse = " & ")
196196
}
197197
# Add a newline to each row, then join in a single string
198-
return(paste(rows, newline, collapse = "\n"))
198+
if(!theme$pagebreak_in_banner) {
199+
return(paste(rows, "\\\\*", collapse = "\n"))
200+
} else {
201+
return(paste(rows, newline, collapse = "\n"))
202+
}
199203
})
200204

201205
# Assemble the components of the table, based on "data_order"
@@ -275,9 +279,9 @@ tableHeader.CrossTabVar <- function(var, theme) {
275279
}
276280

277281
nopagebreak <- NULL
278-
if (!theme$pagebreak_in_banner) {
279-
nopagebreak <- "\\begin{absolutelynopagebreak}"
280-
}
282+
# if (!theme$pagebreak_in_banner) {
283+
# nopagebreak <- "\\begin{absolutelynopagebreak}"
284+
# }
281285

282286
header <- paste(
283287
nopagebreak,

R/writeLatex.R

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,13 @@ latexReportTables <- function(results, banner, theme) {
222222
# bottomrule gets wiped out by nopagebreak environment
223223
# adding one manually
224224
if (!theme$pagebreak_in_banner) {
225-
# table <- gsub(
226-
# "\\end{longtable}",
227-
# "\\bottomrule\\end{longtable}\n",
228-
# table,
229-
# fixed = TRUE
230-
# )
231-
232-
table <- noBreaks(table)
225+
table <- gsub(
226+
"\\end{longtable}",
227+
"\\bottomrule\\end{longtable}\n", # \\end{absolutelynopagebreak}",
228+
table, fixed = TRUE)
233229
}
234230

231+
235232
table_bodies[[i]] <- table
236233
}
237234

tests/testthat/test-catArrayToCategoricals.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ context("catArrayToCategoricals")
22

33
test_that("Binds categorical arrays appropriately", {
44
questions <- readRDS(test_path("fixtures/catArrayToCategorical_questions.rds"))
5-
res <- catArrayToCategoricals(questions, "petloc", labels = NULL)
5+
res <- expect_warning(
6+
catArrayToCategoricals(questions, "petloc", labels = NULL),
7+
"New variables derived from a"
8+
)
69

710
expect_equal(
811
res$petloc_1$crosstabs$Results$`___total___`$proportions,

tests/testthat/test-write-latex.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ test_that("Adds nonTabBookSummary as expected", {
201201

202202
res <- latexReportTables(results, NULL, tema)
203203

204-
# Expect absolutelynopagebreak wraps on all
204+
# Expect absolutelynopagebreak wraps on none!
205205
expect_true(
206-
all(grepl("absolutelynopagebreak", res))
206+
all(!grepl("absolutelynopagebreak", res))
207207
)
208208

209209
# Clear page not appended to results

0 commit comments

Comments
 (0)