Skip to content

Commit be54455

Browse files
style_tt snapshots
1 parent 8a50c9c commit be54455

File tree

8 files changed

+311
-2
lines changed

8 files changed

+311
-2
lines changed

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.0.3 tutorial will take you much further. It is
138+
The `tinytable` 0.15.0.1 tutorial will take you much further. It is
139139
available in HTML and PDF formats at:
140140
<https://vincentarelbundock.github.io/tinytable/>
141141

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
+------+-----+------+-----+------+
2+
| e | f | |
3+
+------+-----+------+-----+------+
4+
| c | d |
5+
+------+-----+------+-----+------+
6+
| | a | b |
7+
+------+-----+------+-----+------+
8+
| mpg | cyl | disp | hp | drat |
9+
+======+=====+======+=====+======+
10+
| 21.0 | 6 | 160 | 110 | 3.90 |
11+
+------+-----+------+-----+------+
12+
| 21.0 | 6 | 160 | 110 | 3.90 |
13+
+------+-----+------+-----+------+
14+
| 22.8 | 4 | 108 | 93 | 3.85 |
15+
+------+-----+------+-----+------+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
\begin{table}
2+
\centering
3+
\begin{tblr}[ %% tabularray outer open
4+
] %% tabularray outer close
5+
{ %% tabularray inner open
6+
colspec={Q[]Q[]Q[]Q[]Q[]},
7+
hline{2}={1-2}{solid, black, 0.05em},
8+
hline{3}={1,4-5}{solid, black, 0.05em},
9+
hline{4}={5}{solid, black, 0.05em},
10+
hline{5}={1-5}{solid, black, 0.05em},
11+
hline{3}={3}{solid, black, 0.05em, l=-0.5},
12+
hline{4}={2,4}{solid, black, 0.05em, l=-0.5},
13+
hline{2}={4}{solid, black, 0.05em, l=-0.5, r=-0.5},
14+
hline{2}={3}{solid, black, 0.05em, r=-0.5},
15+
hline{3}={2}{solid, black, 0.05em, r=-0.5},
16+
hline{4}={3}{solid, black, 0.05em, r=-0.5},
17+
hline{1}={1-5}{solid, black, 0.1em},
18+
hline{8}={1-5}{solid, black, 0.1em},
19+
cell{1-2}{2}={}{halign=c},
20+
cell{1-2}{4}={}{halign=c},
21+
cell{1-3}{5}={}{halign=c},
22+
cell{1,3}{3}={}{halign=c},
23+
cell{1}{1}={c=3}{halign=c},
24+
cell{2}{1}={c=2}{halign=c},
25+
cell{2}{3}={c=3}{halign=c},
26+
cell{3}{1}={}{halign=c},
27+
cell{3}{2}={c=2}{halign=c},
28+
cell{3}{4}={c=2}{halign=c},
29+
} %% tabularray inner close
30+
e & & & f & \\
31+
c & & d & & \\
32+
& a & & b & \\
33+
mpg & cyl & disp & hp & drat \\
34+
21.0 & 6 & 160 & 110 & 3.90 \\
35+
21.0 & 6 & 160 & 110 & 3.90 \\
36+
22.8 & 4 & 108 & 93 & 3.85 \\
37+
\end{tblr}
38+
\end{table}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#show figure: set block(breakable: true)
2+
#figure( // start preamble figure
3+
4+
kind: "tinytable",
5+
supplement: "Table", // end preamble figure
6+
7+
block[ // start block
8+
9+
#let style-dict = (
10+
// tinytable style-dict after
11+
"0_0": 0, "1_0": 0, "2_0": 0, "0_1": 0, "1_1": 0, "2_1": 0, "0_2": 0, "1_2": 0, "2_2": 0, "0_3": 0, "1_3": 0, "2_3": 0, "0_4": 0, "1_4": 0, "2_4": 0
12+
)
13+
14+
#let style-array = (
15+
// tinytable cell style after
16+
(align: center,),
17+
)
18+
19+
// Helper function to get cell style
20+
#let get-style(x, y) = {
21+
let key = str(y) + "_" + str(x)
22+
if key in style-dict { style-array.at(style-dict.at(key)) } else { none }
23+
}
24+
25+
// tinytable align-default-array before
26+
#let align-default-array = ( left, left, left, left, left, ) // tinytable align-default-array here
27+
#show table.cell: it => {
28+
if style-array.len() == 0 { return it }
29+
30+
let style = get-style(it.x, it.y)
31+
if style == none { return it }
32+
33+
let tmp = it
34+
if ("fontsize" in style) { tmp = text(size: style.fontsize, tmp) }
35+
if ("color" in style) { tmp = text(fill: style.color, tmp) }
36+
if ("indent" in style) { tmp = pad(left: style.indent, tmp) }
37+
if ("underline" in style) { tmp = underline(tmp) }
38+
if ("italic" in style) { tmp = emph(tmp) }
39+
if ("bold" in style) { tmp = strong(tmp) }
40+
if ("mono" in style) { tmp = math.mono(tmp) }
41+
if ("strikeout" in style) { tmp = strike(tmp) }
42+
if ("smallcaps" in style) { tmp = smallcaps(tmp) }
43+
tmp
44+
}
45+
46+
#align(center, [
47+
48+
#table( // tinytable table start
49+
column-gutter: 5pt,
50+
columns: (auto, auto, auto, auto, auto),
51+
stroke: none,
52+
rows: auto,
53+
align: (x, y) => {
54+
let style = get-style(x, y)
55+
if style != none and "align" in style { style.align } else { left }
56+
},
57+
fill: (x, y) => {
58+
let style = get-style(x, y)
59+
if style != none and "background" in style { style.background }
60+
},
61+
table.hline(y: 1, start: 0, end: 3, stroke: 0.05em + black), table.hline(y: 1, start: 3, end: 4, stroke: 0.05em + black), table.hline(y: 1, start: 3, end: 4, stroke: 0.05em + black),
62+
table.hline(y: 2, start: 0, end: 1, stroke: 0.05em + black), table.hline(y: 2, start: 0, end: 2, stroke: 0.05em + black), table.hline(y: 2, start: 2, end: 2, stroke: 0.05em + black), table.hline(y: 2, start: 1, end: 2, stroke: 0.05em + black), table.hline(y: 2, start: 2, end: 2, stroke: 0.05em + black), table.hline(y: 2, start: 2, end: 3, stroke: 0.05em + black), table.hline(y: 2, start: 2, end: 4, stroke: 0.05em + black), table.hline(y: 2, start: 3, end: 5, stroke: 0.05em + black), table.hline(y: 2, start: 4, end: 5, stroke: 0.05em + black),
63+
table.hline(y: 3, start: 1, end: 2, stroke: 0.05em + black), table.hline(y: 3, start: 1, end: 2, stroke: 0.05em + black), table.hline(y: 3, start: 1, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 2, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 2, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 3, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 4, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 4, stroke: 0.05em + black), table.hline(y: 3, start: 3, end: 5, stroke: 0.05em + black), table.hline(y: 3, start: 4, end: 5, stroke: 0.05em + black), table.hline(y: 3, start: 4, end: 5, stroke: 0.05em + black),
64+
table.hline(y: 4, start: 0, end: 5, stroke: 0.05em + black),
65+
table.hline(y: 7, start: 0, end: 5, stroke: 0.1em + black),
66+
table.hline(y: 0, start: 0, end: 5, stroke: 0.1em + black),
67+
// tinytable lines before
68+
69+
// tinytable header start
70+
table.header(
71+
repeat: true,
72+
table.cell(colspan: 3, align: center)[e], [f], [ ],
73+
table.cell(colspan: 2, align: center)[c], table.cell(colspan: 3, align: center)[d],
74+
[ ], table.cell(colspan: 2, align: center)[a], table.cell(colspan: 2, align: center)[b],
75+
[mpg], [cyl], [disp], [hp], [drat],
76+
),
77+
// tinytable header end
78+
79+
// tinytable cell content after
80+
[21.0], [6], [160], [110], [3.90],
81+
[21.0], [6], [160], [110], [3.90],
82+
[22.8], [4], [108], [93], [3.85],
83+
84+
// tinytable footer after
85+
86+
) // end table
87+
88+
]) // end align
89+
90+
] // end block
91+
) // end figure
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!-- preamble start -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>tinytable_gjlpbn7aq2pdz7mm1pk6</title>
8+
9+
</head>
10+
<body>
11+
<!-- preamble end -->
12+
13+
<script src="https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js"></script>
14+
15+
<script>
16+
// Create table-specific functions using external factory
17+
const tableFns_gjlpbn7aq2pdz7mm1pk6 = TinyTable.createTableFunctions("tinytable_gjlpbn7aq2pdz7mm1pk6");
18+
// tinytable span after
19+
window.addEventListener('load', function () {
20+
var cellsToStyle = [
21+
// tinytable style arrays after
22+
{ positions: [ { i: '2', j: 1 }, { i: '2', j: 2 } ], css_id: 'tinytable_css_w8c3i33cjtj1o3h9bc1z',},
23+
{ positions: [ { i: '0', j: 1 }, { i: '0', j: 2 } ], css_id: 'tinytable_css_q4r8c5p90qhfgxiekqex',},
24+
];
25+
26+
// Loop over the arrays to style the cells
27+
cellsToStyle.forEach(function (group) {
28+
group.positions.forEach(function (cell) {
29+
tableFns_gjlpbn7aq2pdz7mm1pk6.styleCell(cell.i, cell.j, group.css_id);
30+
});
31+
});
32+
});
33+
</script>
34+
35+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css">
36+
<style>
37+
/* tinytable css entries after */
38+
#tinytable_gjlpbn7aq2pdz7mm1pk6 td.tinytable_css_w8c3i33cjtj1o3h9bc1z, #tinytable_gjlpbn7aq2pdz7mm1pk6 th.tinytable_css_w8c3i33cjtj1o3h9bc1z { position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: black; --line-color-left: black; --line-color-right: black; --line-color-top: black; --line-width-bottom: 0.1em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; }
39+
#tinytable_gjlpbn7aq2pdz7mm1pk6 td.tinytable_css_q4r8c5p90qhfgxiekqex, #tinytable_gjlpbn7aq2pdz7mm1pk6 th.tinytable_css_q4r8c5p90qhfgxiekqex { position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: black; --line-color-left: black; --line-color-right: black; --line-color-top: black; --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; }
40+
</style>
41+
<div class="container">
42+
<table class="tinytable" id="tinytable_gjlpbn7aq2pdz7mm1pk6" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing='true'>
43+
44+
<thead>
45+
<tr>
46+
<th scope="col" data-row="0" data-col="1">Species</th>
47+
<th scope="col" data-row="0" data-col="2">Image</th>
48+
</tr>
49+
</thead>
50+
51+
<tbody>
52+
<tr>
53+
<td data-row="1" data-col="1">Spider</td>
54+
<td data-row="1" data-col="2"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeLPSPrPtVgPg6BLCiN6lBYy8l1xNy0T5yttVjkIk0L3Rva8Zl" style="height: 3em;"></td>
55+
</tr>
56+
<tr>
57+
<td data-row="2" data-col="1">Squirrel</td>
58+
<td data-row="2" data-col="2"><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQdBlFVajljNz5qMbO622ihkIU2r6yA5whM9b8MbRGKOfJ8_UmZ" style="height: 3em;"></td>
59+
</tr>
60+
</tbody>
61+
</table>
62+
</div>
63+
<!-- postamble start -->
64+
</body>
65+
66+
</html>
67+
<!-- postamble end -->
68+
<!-- hack to avoid NA insertion in last line -->
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!-- preamble start -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>tinytable_660jeh56sd5ooc2n7hgf</title>
8+
9+
</head>
10+
<body>
11+
<!-- preamble end -->
12+
13+
<script src="https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.js"></script>
14+
15+
<script>
16+
// Create table-specific functions using external factory
17+
const tableFns_660jeh56sd5ooc2n7hgf = TinyTable.createTableFunctions("tinytable_660jeh56sd5ooc2n7hgf");
18+
// tinytable span after
19+
window.addEventListener('load', function () {
20+
var cellsToStyle = [
21+
// tinytable style arrays after
22+
{ positions: [ { i: '2', j: 1 }, { i: '2', j: 2 } ], css_id: 'tinytable_css_qhpl1z38uko4e4x79w9w',},
23+
{ positions: [ { i: '0', j: 1 }, { i: '0', j: 2 } ], css_id: 'tinytable_css_bavw76jtgiiws37e1cx9',},
24+
];
25+
26+
// Loop over the arrays to style the cells
27+
cellsToStyle.forEach(function (group) {
28+
group.positions.forEach(function (cell) {
29+
tableFns_660jeh56sd5ooc2n7hgf.styleCell(cell.i, cell.j, group.css_id);
30+
});
31+
});
32+
});
33+
</script>
34+
35+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/vincentarelbundock/tinytable@main/inst/tinytable.css">
36+
<style>
37+
/* tinytable css entries after */
38+
#tinytable_660jeh56sd5ooc2n7hgf td.tinytable_css_qhpl1z38uko4e4x79w9w, #tinytable_660jeh56sd5ooc2n7hgf th.tinytable_css_qhpl1z38uko4e4x79w9w { position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 0; --line-color-bottom: black; --line-color-left: black; --line-color-right: black; --line-color-top: black; --line-width-bottom: 0.1em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; }
39+
#tinytable_660jeh56sd5ooc2n7hgf td.tinytable_css_bavw76jtgiiws37e1cx9, #tinytable_660jeh56sd5ooc2n7hgf th.tinytable_css_bavw76jtgiiws37e1cx9 { position: relative; --border-bottom: 1; --border-left: 0; --border-right: 0; --border-top: 1; --line-color-bottom: black; --line-color-left: black; --line-color-right: black; --line-color-top: black; --line-width-bottom: 0.05em; --line-width-left: 0.1em; --line-width-right: 0.1em; --line-width-top: 0.1em; --trim-bottom-left: 0%; --trim-bottom-right: 0%; --trim-left-bottom: 0%; --trim-left-top: 0%; --trim-right-bottom: 0%; --trim-right-top: 0%; --trim-top-left: 0%; --trim-top-right: 0%; }
40+
</style>
41+
<div class="container">
42+
<table class="tinytable" id="tinytable_660jeh56sd5ooc2n7hgf" style="width: auto; margin-left: auto; margin-right: auto;" data-quarto-disable-processing='true'>
43+
44+
<thead>
45+
<tr>
46+
<th scope="col" data-row="0" data-col="1">Species</th>
47+
<th scope="col" data-row="0" data-col="2">Image</th>
48+
</tr>
49+
</thead>
50+
51+
<tbody>
52+
<tr>
53+
<td data-row="1" data-col="1">Spider</td>
54+
<td data-row="1" data-col="2"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSeLPSPrPtVgPg6BLCiN6lBYy8l1xNy0T5yttVjkIk0L3Rva8Zl" style="height: 3em;"></td>
55+
</tr>
56+
<tr>
57+
<td data-row="2" data-col="1">Squirrel</td>
58+
<td data-row="2" data-col="2"><img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQdBlFVajljNz5qMbO622ihkIU2r6yA5whM9b8MbRGKOfJ8_UmZ" style="height: 3em;"></td>
59+
</tr>
60+
</tbody>
61+
</table>
62+
</div>
63+
<!-- postamble start -->
64+
</body>
65+
66+
</html>
67+
<!-- postamble end -->
68+
<!-- hack to avoid NA insertion in last line -->
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
\begin{table}
2+
\centering
3+
\begin{tblr}[ %% tabularray outer open
4+
] %% tabularray outer close
5+
{ %% tabularray inner open
6+
colspec={Q[]Q[]Q[]Q[]Q[]},
7+
hline{2}={1-5}{solid, black, 0.05em},
8+
hline{1}={1-5}{solid, black, 0.1em},
9+
hline{8}={1-5}{solid, black, 0.1em},
10+
cell{2-3,5,7}{1}={}{bg=cFFA500},
11+
cell{2,4}{3}={}{bg=c00FF00},
12+
cell{2,7}{2}={}{bg=c00FF00},
13+
cell{3-4,6}{2}={}{bg=cFFA500},
14+
cell{3,6-7}{5}={}{bg=c00FF00},
15+
cell{4-5}{5}={}{bg=cFFA500},
16+
cell{5-6}{4}={}{bg=c00FF00},
17+
cell{5}{3}={}{bg=cFFA500},
18+
} %% tabularray inner close
19+
\tinytableDefineColor{c00FF00}{HTML}{00FF00}
20+
\tinytableDefineColor{cFFA500}{HTML}{FFA500}
21+
Sepal.Length & Sepal.Width & Petal.Length & Petal.Width & Species \\
22+
5.1 & 3.5 & 1.4 & 0.2 & setosa \\
23+
4.9 & 3.0 & 1.4 & 0.2 & setosa \\
24+
4.7 & 3.2 & 1.3 & 0.2 & setosa \\
25+
4.6 & 3.1 & 1.5 & 0.2 & setosa \\
26+
5.0 & 3.6 & 1.4 & 0.2 & setosa \\
27+
5.4 & 3.9 & 1.7 & 0.4 & setosa \\
28+
\end{tblr}
29+
\end{table}

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)