Skip to content

Commit

Permalink
same treatment for listingtable
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrumbiegel committed Sep 16, 2024
1 parent 0113479 commit 1bbca8a
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/table.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ function _listingtable(
ungroup = false
)

gdf_rows = DataFrames.groupby(df, rowsymbols, sort = false)
gdf_rows = DataFrames.groupby(df, rowsymbols, sort = sort ? (; lt = natural_lt) : false)
row_keys = Tuple.(keys(gdf_rows))
gdf_cols = DataFrames.groupby(df, colsymbols, sort = false)
gdf_cols = DataFrames.groupby(df, colsymbols, sort = sort ? (; lt = natural_lt) : false)
col_keys = Tuple.(keys(gdf_cols))

lt = ListingTable(
Expand Down
24 changes: 24 additions & 0 deletions test/references/listingtable/missing_groups.latex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
\documentclass{article}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
\begin{table}[!ht]
\setlength\tabcolsep{0pt}
\centering
\begin{threeparttable}
\begin{tabular}{@{\extracolsep{2ex}}*{4}{lccc}}
\toprule
& \multicolumn{3}{c}{\textbf{B}} \\
\cmidrule{2-4}
& 2 & 4 & 8 \\
\textbf{A} & \multicolumn{3}{c}{\textbf{value}} \\
\midrule
'a' & & 6 & \\
'b' & 4 & 5 & \\
'c' & 2 & 1 & 3 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}
65 changes: 65 additions & 0 deletions test/references/listingtable/missing_groups.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<table class="st-cb1156a1">
<style>
.st-cb1156a1 {
border: none;
margin: 0 auto;
padding: 0.25rem;
border-collapse: separate;
border-spacing: 0.85em 0.2em;
line-height: 1.2em;
}

.st-cb1156a1 tr td {
vertical-align: top;
padding: 0;
border: none;
}

.st-cb1156a1 br {
line-height: 0em;
margin: 0;
}

.st-cb1156a1 sub {
line-height: 0;
}

.st-cb1156a1 sup {
line-height: 0;
}
</style>
<tr><td colspan="4" style="border-bottom: 1.5px solid black; padding: 0"></td></tr>
<tr>
<td style="text-align:center;"></td>
<td colspan="3" style="font-weight:bold;border-bottom:1px solid black; padding-bottom: 0.25em;text-align:center;">B</td>
</tr>
<tr>
<td style="text-align:center;"></td>
<td style="text-align:center;">2</td>
<td style="text-align:center;">4</td>
<td style="text-align:center;">8</td>
</tr>
<tr>
<td style="font-weight:bold;text-align:left;">A</td>
<td colspan="3" style="font-weight:bold;text-align:center;">value</td>
</tr>
<tr><td colspan="4" style="border-bottom:1px solid black;padding:0"></td></tr> <tr>
<td style="text-align:left;">&apos;a&apos;</td>
<td style="text-align:center;"></td>
<td style="text-align:center;">6</td>
<td style="text-align:center;"></td>
</tr>
<tr>
<td style="text-align:left;">&apos;b&apos;</td>
<td style="text-align:center;">4</td>
<td style="text-align:center;">5</td>
<td style="text-align:center;"></td>
</tr>
<tr>
<td style="text-align:left;">&apos;c&apos;</td>
<td style="text-align:center;">2</td>
<td style="text-align:center;">1</td>
<td style="text-align:center;">3</td>
</tr>
<tr><td colspan="4" style="border-bottom: 1.5px solid black; padding: 0"></td></tr>
</table>
32 changes: 32 additions & 0 deletions test/references/listingtable/missing_groups.typ.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#table(
rows: 6,
columns: 4,
column-gutter: 0.25em,
align: (left, center, center, center),
stroke: none,
table.hline(y: 0, stroke: 1pt),
[],
table.cell(colspan: 3)[*B*],
table.hline(y: 1, start: 1, end: 4, stroke: 0.75pt),
[],
[2],
[4],
[8],
[*A*],
table.cell(colspan: 3)[*value*],
table.hline(y: 3, stroke: 0.75pt),
['a'],
[],
[6],
[],
['b'],
[4],
[5],
[],
['c'],
[2],
[1],
[3],
table.hline(y: 6, stroke: 1pt),
)
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ end
for (i, page) in enumerate(pt.pages)
reftest(t, "references/listingtable/pagination_rows=2_summarized_grouplevel_1_$i")
end

t = listingtable(df_missing_groups, :value, rows = :A, cols = :B)
reftest(t, "references/listingtable/missing_groups")
end

@testset "summarytable" begin
Expand Down

0 comments on commit 1bbca8a

Please sign in to comment.