From 1bbca8a33e96e93cbcb4f1479804958d079386ba Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 16 Sep 2024 10:25:44 +0200 Subject: [PATCH] same treatment for listingtable --- src/table.jl | 4 +- .../listingtable/missing_groups.latex.txt | 24 +++++++ .../listingtable/missing_groups.txt | 65 +++++++++++++++++++ .../listingtable/missing_groups.typ.txt | 32 +++++++++ test/runtests.jl | 3 + 5 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 test/references/listingtable/missing_groups.latex.txt create mode 100644 test/references/listingtable/missing_groups.txt create mode 100644 test/references/listingtable/missing_groups.typ.txt diff --git a/src/table.jl b/src/table.jl index 2b1296e..7a65b5b 100644 --- a/src/table.jl +++ b/src/table.jl @@ -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( diff --git a/test/references/listingtable/missing_groups.latex.txt b/test/references/listingtable/missing_groups.latex.txt new file mode 100644 index 0000000..816c0bd --- /dev/null +++ b/test/references/listingtable/missing_groups.latex.txt @@ -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} \ No newline at end of file diff --git a/test/references/listingtable/missing_groups.txt b/test/references/listingtable/missing_groups.txt new file mode 100644 index 0000000..69200a6 --- /dev/null +++ b/test/references/listingtable/missing_groups.txt @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
B
248
Avalue
'a'6
'b'45
'c'213
\ No newline at end of file diff --git a/test/references/listingtable/missing_groups.typ.txt b/test/references/listingtable/missing_groups.typ.txt new file mode 100644 index 0000000..3883b69 --- /dev/null +++ b/test/references/listingtable/missing_groups.typ.txt @@ -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), +) diff --git a/test/runtests.jl b/test/runtests.jl index e6d93c0..37bb141 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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