Skip to content

Commit b56364d

Browse files
Issue #614 (#615)
1 parent 7002636 commit b56364d

File tree

5 files changed

+40
-38
lines changed

5 files changed

+40
-38
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: tinytable
22
Type: Package
33
Title: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats
44
Description: Create highly customized tables with this simple and dependency-free package. Data frames can be converted to 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', or 'Typst' tables. The user interface is minimalist and easy to learn. The syntax is concise. 'HTML' tables can be customized using the flexible 'Bootstrap' framework, and 'LaTeX' code with the 'tabularray' package.
5-
Version: 0.15.1.3
5+
Version: 0.15.1.4
66
Imports:
77
methods
88
Depends:

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Bugs:
77
* Tabulator HTML output now preserves special characters in column names like question marks (Issue #611, thanks to @etiennebacher).
88
* Document `rbind2()` limitations around `format_tt()`/`style_tt()` and string coercion when stacking tables (Issue #612, thanks to @alexploner).
99
* `theme_latex(environment = "tabular")` now preserves captions (Issue #613, thanks to @brueckmann).
10+
* LaTeX tables again respect automatic wrapping when spanning horizontal cells by propagating `tt(width = ...)` across merged columns (Issue #614, thanks to @bastienchassagnol).
1011

1112
## 0.15.1
1213

R/tabularray_style.R

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ map_alignv_values <- function(sty) {
1818
style_text <- function(sty_row) {
1919
font <- ""
2020
cmd <- ""
21-
21+
2222
# Use descriptive font commands for tabularray font key
2323
if (isTRUE(sty_row$bold)) {
2424
font <- paste0(font, "\\bfseries")
@@ -32,15 +32,15 @@ style_text <- function(sty_row) {
3232
if (isTRUE(sty_row$smallcap)) {
3333
font <- paste0(font, "\\scshape")
3434
}
35-
35+
3636
# Keep underline and strikeout as cmd since they need special macros
3737
if (isTRUE(sty_row$underline)) {
3838
cmd <- paste0(cmd, "\\tinytableTabularrayUnderline")
3939
}
4040
if (isTRUE(sty_row$strikeout)) {
4141
cmd <- paste0(cmd, "\\tinytableTabularrayStrikeout")
4242
}
43-
43+
4444
return(list(font = font, cmd = cmd))
4545
}
4646

@@ -140,7 +140,7 @@ clean_style_strings <- function(k) {
140140

141141
# Split by comma and remove duplicates
142142
parts <- trimws(strsplit(style_string, ",")[[1]])
143-
parts <- parts[parts != ""] # Remove empty parts
143+
parts <- parts[parts != ""] # Remove empty parts
144144
unique_parts <- unique(parts)
145145

146146
# Rejoin with proper spacing
@@ -258,8 +258,7 @@ tabularray_cells <- function(x, rec) {
258258
rec[
259259
(rec$span != "" | rec$set != "") &
260260
!rec$complete_row &
261-
!rec$complete_column,
262-
,
261+
!rec$complete_column, ,
263262
drop = FALSE
264263
]
265264
)
@@ -446,6 +445,10 @@ process_tabularray_other_styles <- function(x, other) {
446445

447446
# Style spans
448447
span_strs[row] <- style_spans("", other[row, ])
448+
if (length(x@width) == ncol(x) && !is.na(other[row, "colspan"])) {
449+
w <- sum(x@width[other$j[row]:(other[row, "j"] + other[row, "colspan"] - 1)])
450+
font_sets[row] <- paste(font_sets[row], sprintf("wd=%s\\linewidth,", w))
451+
}
449452
}
450453

451454
# Apply styling to record grid (still need loop for NA expansion)
@@ -645,36 +648,36 @@ setMethod(
645648
f = "style_eval",
646649
signature = "tinytable_tabularray",
647650
definition = function(
648-
x,
649-
i = NULL,
650-
j = NULL,
651-
bold = FALSE,
652-
italic = FALSE,
653-
monospace = FALSE,
654-
underline = FALSE,
655-
strikeout = FALSE,
656-
color = NULL,
657-
background = NULL,
658-
fontsize = NULL,
659-
align = NULL,
660-
alignv = NULL,
661-
line = NULL,
662-
line_color = "black",
663-
line_width = 0.1,
664-
colspan = NULL,
665-
rowspan = NULL,
666-
indent = 0,
667-
...
668-
) {
651+
x,
652+
i = NULL,
653+
j = NULL,
654+
bold = FALSE,
655+
italic = FALSE,
656+
monospace = FALSE,
657+
underline = FALSE,
658+
strikeout = FALSE,
659+
color = NULL,
660+
background = NULL,
661+
fontsize = NULL,
662+
align = NULL,
663+
alignv = NULL,
664+
line = NULL,
665+
line_color = "black",
666+
line_width = 0.1,
667+
colspan = NULL,
668+
rowspan = NULL,
669+
indent = 0,
670+
...) {
669671
# Use populated @style_other from build_tt()
670672
other <- x@style_other
671673

672674
# Filter to only cells that have actual styles
673675
if (nrow(other) > 0) {
674-
has_style <- rowSums(!is.na(other[, c("bold", "italic", "underline", "strikeout",
675-
"monospace", "smallcap", "align", "alignv",
676-
"color", "background", "fontsize", "indent",
677-
"colspan", "rowspan"), drop = FALSE])) > 0
676+
has_style <- rowSums(!is.na(other[, c(
677+
"bold", "italic", "underline", "strikeout",
678+
"monospace", "smallcap", "align", "alignv",
679+
"color", "background", "fontsize", "indent",
680+
"colspan", "rowspan"), drop = FALSE])) > 0
678681
other <- other[has_style, , drop = FALSE]
679682
}
680683

@@ -691,15 +694,13 @@ setMethod(
691694
x <- process_tabularray_other_styles(x, other)
692695

693696
return(x)
694-
}
695-
)
697+
})
696698

697699
insert_tabularray_content <- function(x, content = NULL, type = "body") {
698700
out <- x
699701

700702
out <- strsplit(out, "\n")[[1]]
701-
comment <- switch(
702-
type,
703+
comment <- switch(type,
703704
"body" = "% tabularray inner close",
704705
"outer" = "% tabularray outer close",
705706
"inner" = "% tabularray inner close"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ tt(x,
135135

136136
## Tutorial
137137

138-
The `tinytable` 0.15.1.2 tutorial will take you much further. It is
138+
The `tinytable` 0.15.1.4 tutorial will take you much further. It is
139139
available in HTML and PDF formats at:
140140
<https://vincentarelbundock.github.io/tinytable/>
141141

man/style_tt.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)