Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: tinytable
Type: Package
Title: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats
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.
Version: 0.15.1.3
Version: 0.15.1.4
Imports:
methods
Depends:
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Bugs:
* Tabulator HTML output now preserves special characters in column names like question marks (Issue #611, thanks to @etiennebacher).
* Document `rbind2()` limitations around `format_tt()`/`style_tt()` and string coercion when stacking tables (Issue #612, thanks to @alexploner).
* `theme_latex(environment = "tabular")` now preserves captions (Issue #613, thanks to @brueckmann).
* LaTeX tables again respect automatic wrapping when spanning horizontal cells by propagating `tt(width = ...)` across merged columns (Issue #614, thanks to @bastienchassagnol).

## 0.15.1

Expand Down
71 changes: 36 additions & 35 deletions R/tabularray_style.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ map_alignv_values <- function(sty) {
style_text <- function(sty_row) {
font <- ""
cmd <- ""

# Use descriptive font commands for tabularray font key
if (isTRUE(sty_row$bold)) {
font <- paste0(font, "\\bfseries")
Expand All @@ -32,15 +32,15 @@ style_text <- function(sty_row) {
if (isTRUE(sty_row$smallcap)) {
font <- paste0(font, "\\scshape")
}

# Keep underline and strikeout as cmd since they need special macros
if (isTRUE(sty_row$underline)) {
cmd <- paste0(cmd, "\\tinytableTabularrayUnderline")
}
if (isTRUE(sty_row$strikeout)) {
cmd <- paste0(cmd, "\\tinytableTabularrayStrikeout")
}

return(list(font = font, cmd = cmd))
}

Expand Down Expand Up @@ -140,7 +140,7 @@ clean_style_strings <- function(k) {

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

# Rejoin with proper spacing
Expand Down Expand Up @@ -258,8 +258,7 @@ tabularray_cells <- function(x, rec) {
rec[
(rec$span != "" | rec$set != "") &
!rec$complete_row &
!rec$complete_column,
,
!rec$complete_column, ,
drop = FALSE
]
)
Expand Down Expand Up @@ -446,6 +445,10 @@ process_tabularray_other_styles <- function(x, other) {

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

# Apply styling to record grid (still need loop for NA expansion)
Expand Down Expand Up @@ -645,36 +648,36 @@ setMethod(
f = "style_eval",
signature = "tinytable_tabularray",
definition = function(
x,
i = NULL,
j = NULL,
bold = FALSE,
italic = FALSE,
monospace = FALSE,
underline = FALSE,
strikeout = FALSE,
color = NULL,
background = NULL,
fontsize = NULL,
align = NULL,
alignv = NULL,
line = NULL,
line_color = "black",
line_width = 0.1,
colspan = NULL,
rowspan = NULL,
indent = 0,
...
) {
x,
i = NULL,
j = NULL,
bold = FALSE,
italic = FALSE,
monospace = FALSE,
underline = FALSE,
strikeout = FALSE,
color = NULL,
background = NULL,
fontsize = NULL,
align = NULL,
alignv = NULL,
line = NULL,
line_color = "black",
line_width = 0.1,
colspan = NULL,
rowspan = NULL,
indent = 0,
...) {
# Use populated @style_other from build_tt()
other <- x@style_other

# Filter to only cells that have actual styles
if (nrow(other) > 0) {
has_style <- rowSums(!is.na(other[, c("bold", "italic", "underline", "strikeout",
"monospace", "smallcap", "align", "alignv",
"color", "background", "fontsize", "indent",
"colspan", "rowspan"), drop = FALSE])) > 0
has_style <- rowSums(!is.na(other[, c(
"bold", "italic", "underline", "strikeout",
"monospace", "smallcap", "align", "alignv",
"color", "background", "fontsize", "indent",
"colspan", "rowspan"), drop = FALSE])) > 0
other <- other[has_style, , drop = FALSE]
}

Expand All @@ -691,15 +694,13 @@ setMethod(
x <- process_tabularray_other_styles(x, other)

return(x)
}
)
})

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

out <- strsplit(out, "\n")[[1]]
comment <- switch(
type,
comment <- switch(type,
"body" = "% tabularray inner close",
"outer" = "% tabularray outer close",
"inner" = "% tabularray inner close"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ tt(x,

## Tutorial

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

Expand Down
2 changes: 1 addition & 1 deletion man/style_tt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.