From bf63eae3de7c92e6dd9c0693095ac069d513502d Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Fri, 20 Sep 2024 13:57:56 +0200 Subject: [PATCH 01/12] add footnote linebreak option to Table and set to `true` by default --- src/cells.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cells.jl b/src/cells.jl index c0395b3..39a7294 100644 --- a/src/cells.jl +++ b/src/cells.jl @@ -111,6 +111,7 @@ struct Table round_digits::Int round_mode::Union{Nothing,Symbol} trailing_zeros::Bool + linebreak_footnotes::Bool end function Table(cells, header, footer; @@ -121,8 +122,9 @@ function Table(cells, header, footer; postprocess = [], rowgaps = Pair{Int,Float64}[], colgaps = Pair{Int,Float64}[], + linebreak_footnotes::Bool = true, ) - Table(cells, header, footer, footnotes, rowgaps, colgaps, postprocess, round_digits, round_mode, trailing_zeros) + Table(cells, header, footer, footnotes, rowgaps, colgaps, postprocess, round_digits, round_mode, trailing_zeros, linebreak_footnotes) end """ @@ -136,6 +138,7 @@ end postprocess = [], rowgaps = Pair{Int,Float64}[], colgaps = Pair{Int,Float64}[], + linebreak_footnotes = true, ) Create a `Table` which can be rendered in multiple formats, such as HTML or LaTeX. @@ -160,6 +163,7 @@ Create a `Table` which can be rendered in multiple formats, such as HTML or LaTe the size of `gap_pt` is added between the rows `index` and `index+1`. - `colgaps = Pair{Int,Float64}[]`: A list of pairs `index => gap_pt`. For each pair, a visual gap the size of `gap_pt` is added between the columns `index` and `index+1`. +- `linebreak_footnotes = true`: If `true`, each footnote and annotation starts on a separate line. ## Round mode @@ -465,7 +469,7 @@ function postprocess_table(ct::Table, any) end return new_cell end - Table(new_cl, ct.header, ct.footer, ct.footnotes, ct.rowgaps, ct.colgaps, [], ct.round_digits, ct.round_mode, ct.trailing_zeros) + Table(new_cl, ct.header, ct.footer, ct.footnotes, ct.rowgaps, ct.colgaps, [], ct.round_digits, ct.round_mode, ct.trailing_zeros, ct.linebreak_footnotes) end function postprocess_table(ct::Table, v::AbstractVector) From 10ebf1598fd55ff86ea6aae7865c2d9d4c5310eb Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Fri, 20 Sep 2024 13:58:11 +0200 Subject: [PATCH 02/12] change html implementation --- src/html.jl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/html.jl b/src/html.jl index 97699db..d28c83c 100644 --- a/src/html.jl +++ b/src/html.jl @@ -90,7 +90,13 @@ function Base.show(io::IO, ::MIME"text/html", ct::Table) if !isempty(annotations) || !isempty(ct.footnotes) print(_io, " ") for (i, (annotation, label)) in enumerate(annotations) - i > 1 && print(_io, "    ") + if i > 1 + if ct.linebreak_footnotes + print(_io, "
") + else + print(_io, "    ") + end + end if label !== NoLabel() print(_io, "") _showas(_io, MIME"text/html"(), label) @@ -99,7 +105,13 @@ function Base.show(io::IO, ::MIME"text/html", ct::Table) _showas(_io, MIME"text/html"(), annotation) end for (i, footnote) in enumerate(ct.footnotes) - (!isempty(annotations) || i > 1) && print(_io, "    ") + if !isempty(annotations) || i > 1 + if ct.linebreak_footnotes + print(_io, "
") + else + print(_io, "    ") + end + end _showas(_io, MIME"text/html"(), footnote) end println(_io, "") From 438ed4661c8b186f1833c4b14ed0cb15feb0c82d Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Fri, 20 Sep 2024 14:08:52 +0200 Subject: [PATCH 03/12] implement typst --- src/typst.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/typst.jl b/src/typst.jl index fd47af2..e531f57 100644 --- a/src/typst.jl +++ b/src/typst.jl @@ -93,8 +93,12 @@ function Base.show(io::IO, M::MIME"text/typst", ct::Table) options = join(filter(!isempty, [align, colspan]), ", ") print(io, " table.cell($options)[") + if (!isempty(annotations) || !isempty(ct.footnotes)) && ct.linebreak_footnotes + print(io, "\n ") + end + for (i, (annotation, label)) in enumerate(annotations) - i > 1 && print(io, "#h(1.5em, weak: true)") + i > 1 && print(io, ct.linebreak_footnotes ? "\\\n " : "#h(1.5em, weak: true)") if label !== NoLabel() print(io, "#super[") _showas(io, MIME"text/typst"(), label) @@ -106,10 +110,14 @@ function Base.show(io::IO, M::MIME"text/typst", ct::Table) end for (i, footnote) in enumerate(ct.footnotes) - (!isempty(annotations) || i > 1) && print(io, "#h(1.5em, weak: true)") + (!isempty(annotations) || i > 1) && print(io, ct.linebreak_footnotes ? "\\\n " : "#h(1.5em, weak: true)") _showas(io, MIME"text/typst"(), footnote) end + if (!isempty(annotations) || !isempty(ct.footnotes)) && ct.linebreak_footnotes + print(io, "\n ") + end + println(io, "],") # table.cell()[ end From a785618407775243360b0111edaba87a9fdbe3ff Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 09:30:34 +0200 Subject: [PATCH 04/12] fix typst footnotes size --- src/typst.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/typst.jl b/src/typst.jl index e531f57..0be41d5 100644 --- a/src/typst.jl +++ b/src/typst.jl @@ -91,7 +91,7 @@ function Base.show(io::IO, M::MIME"text/typst", ct::Table) align = _align(CellStyle(halign = :left), 1) colspan = "colspan: $(size(matrix, 2))" options = join(filter(!isempty, [align, colspan]), ", ") - print(io, " table.cell($options)[") + print(io, " table.cell($options)[#text(size: 0.8em)[") if (!isempty(annotations) || !isempty(ct.footnotes)) && ct.linebreak_footnotes print(io, "\n ") @@ -104,9 +104,7 @@ function Base.show(io::IO, M::MIME"text/typst", ct::Table) _showas(io, MIME"text/typst"(), label) print(io, "]") end - print(io, "#text(size: 0.8em)[") _showas(io, MIME"text/typst"(), annotation) - print(io, "]") end for (i, footnote) in enumerate(ct.footnotes) @@ -118,7 +116,7 @@ function Base.show(io::IO, M::MIME"text/typst", ct::Table) print(io, "\n ") end - println(io, "],") # table.cell()[ + println(io, "]],") # table.cell()[#text(..)[ end println(io, ")") # table() From 5db0b2cc47da6312b5cfcad273bd9e6ec9270312 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 09:39:07 +0200 Subject: [PATCH 05/12] implement docx --- src/docx.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/docx.jl b/src/docx.jl index 2b15775..b8ba892 100644 --- a/src/docx.jl +++ b/src/docx.jl @@ -80,10 +80,12 @@ function to_docx(ct::Table) push!(tablerows, full_width_border_row(DOCX_OUTER_RULE_SIZE)) + separator_element = ct.linebreak_footnotes ? WriteDocx.Break() : WriteDocx.Text(" ") + if !isempty(annotations) || !isempty(ct.footnotes) elements = [] for (i, (annotation, label)) in enumerate(annotations) - i > 1 && push!(elements, WriteDocx.Run([WriteDocx.Text(" ")])) + i > 1 && push!(elements, WriteDocx.Run([separator_element])) if label !== NoLabel() push!(elements, WriteDocx.Run([WriteDocx.Text(docx_sprint(label)), WriteDocx.Text(" ")], WriteDocx.RunProperties(valign = WriteDocx.VerticalAlignment.superscript))) @@ -92,7 +94,7 @@ function to_docx(ct::Table) WriteDocx.RunProperties(size = DOCX_ANNOTATION_FONTSIZE))) end for (i, footnote) in enumerate(ct.footnotes) - (!isempty(annotations) || i > 1) && push!(elements, WriteDocx.Run([WriteDocx.Text(" ")])) + (!isempty(annotations) || i > 1) && push!(elements, WriteDocx.Run([separator_element])) push!(elements, WriteDocx.Run([WriteDocx.Text(docx_sprint(footnote))], WriteDocx.RunProperties(size = DOCX_ANNOTATION_FONTSIZE))) end From 7be6c09c39ee75f1ed0817aa66fc6d27e5820a59 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 09:56:08 +0200 Subject: [PATCH 06/12] fix latex --- src/latex.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/latex.jl b/src/latex.jl index 9347bd1..aa47758 100644 --- a/src/latex.jl +++ b/src/latex.jl @@ -118,7 +118,7 @@ function Base.show(io::IO, ::MIME"text/latex", ct::Table) \end{tabular} """) if !isempty(annotations) || !isempty(ct.footnotes) - println(io, raw"\begin{tablenotes}[flushleft,para]") + println(io, "\\begin{tablenotes}[flushleft$(ct.linebreak_footnotes ? "" : ",para")]") println(io, raw"\footnotesize") for (annotation, label) in annotations if label !== NoLabel() From 1ad64181e4f411c5974b6bfe3d915d13c9301fba Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 09:56:18 +0200 Subject: [PATCH 07/12] add tests --- test/runtests.jl | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 8ea37a3..eb9f81f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -475,27 +475,27 @@ end end @testset "manual footnotes" begin - t = Table( - [ - SpannedCell(1, 1, "Cell 1"), - SpannedCell(1, 2, "Cell 2"), - ], - nothing, - nothing, - footnotes = ["First footnote.", "Second footnote."] - ) - reftest(t, "references/manual_footnotes/footnotes") - - t = Table( - [ - SpannedCell(1, 1, Annotated("Cell 1", "Note 1")), - SpannedCell(1, 2, "Cell 2"), - ], - nothing, - nothing, - footnotes = ["First footnote.", "Second footnote."] - ) - reftest(t, "references/manual_footnotes/footnotes_and_annotated") + for linebreak_footnotes in [true, false] + t = Table( + [ + SpannedCell(1, 1, "Cell 1"), + SpannedCell(1, 2, "Cell 2"), + ]; + footnotes = ["First footnote.", "Second footnote."], + linebreak_footnotes, + ) + reftest(t, "references/manual_footnotes/footnotes_linebreaks_$linebreak_footnotes") + + t = Table( + [ + SpannedCell(1, 1, Annotated("Cell 1", "Note 1")), + SpannedCell(1, 2, "Cell 2"), + ]; + footnotes = ["First footnote.", "Second footnote."], + linebreak_footnotes, + ) + reftest(t, "references/manual_footnotes/footnotes_and_annotated_linebreaks_$linebreak_footnotes") + end end @testset "Replace" begin From a8902bead75d211fc080415f9555b96719e30a95 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 09:57:57 +0200 Subject: [PATCH 08/12] update references --- .../annotations/annotated_float.latex.txt | 2 +- .../annotations/annotated_float.typ.txt | 4 +- .../automatic_annotations.docx.txt | 4 +- .../automatic_annotations.latex.txt | 2 +- .../annotations/automatic_annotations.txt | 14 +- .../annotations/automatic_annotations.typ.txt | 6 +- .../annotations/manual_annotations.docx.txt | 6 +- .../annotations/manual_annotations.latex.txt | 2 +- .../annotations/manual_annotations.txt | 14 +- .../annotations/manual_annotations.typ.txt | 7 +- ...s_and_annotated_linebreaks_false.docx.txt} | 0 ..._and_annotated_linebreaks_false.latex.txt} | 0 ...tnotes_and_annotated_linebreaks_false.txt} | 0 ...es_and_annotated_linebreaks_false.typ.txt} | 2 +- ...tes_and_annotated_linebreaks_true.docx.txt | 302 ++++++++++++++++++ ...es_and_annotated_linebreaks_true.latex.txt | 23 ++ ...ootnotes_and_annotated_linebreaks_true.txt | 38 +++ ...otes_and_annotated_linebreaks_true.typ.txt | 17 + ...xt => footnotes_linebreaks_false.docx.txt} | 0 ...t => footnotes_linebreaks_false.latex.txt} | 0 ...tes.txt => footnotes_linebreaks_false.txt} | 0 ...txt => footnotes_linebreaks_false.typ.txt} | 2 +- .../footnotes_linebreaks_true.docx.txt | 279 ++++++++++++++++ .../footnotes_linebreaks_true.latex.txt | 22 ++ .../footnotes_linebreaks_true.txt | 38 +++ .../footnotes_linebreaks_true.typ.txt | 16 + .../merged_cells/custom_datatypes.latex.txt | 2 +- .../merged_cells/custom_datatypes.typ.txt | 4 +- .../replace/replacemissing_default.latex.txt | 2 +- .../replace/replacemissing_default.typ.txt | 4 +- .../table_one/all_missing_group.latex.txt | 2 +- .../table_one/all_missing_group.typ.txt | 4 +- 32 files changed, 785 insertions(+), 33 deletions(-) rename test/references/manual_footnotes/{footnotes_and_annotated.docx.txt => footnotes_and_annotated_linebreaks_false.docx.txt} (100%) rename test/references/manual_footnotes/{footnotes_and_annotated.latex.txt => footnotes_and_annotated_linebreaks_false.latex.txt} (100%) rename test/references/manual_footnotes/{footnotes_and_annotated.txt => footnotes_and_annotated_linebreaks_false.txt} (100%) rename test/references/manual_footnotes/{footnotes_and_annotated.typ.txt => footnotes_and_annotated_linebreaks_false.typ.txt} (59%) create mode 100644 test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.docx.txt create mode 100644 test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.latex.txt create mode 100644 test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.txt create mode 100644 test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.typ.txt rename test/references/manual_footnotes/{footnotes.docx.txt => footnotes_linebreaks_false.docx.txt} (100%) rename test/references/manual_footnotes/{footnotes.latex.txt => footnotes_linebreaks_false.latex.txt} (100%) rename test/references/manual_footnotes/{footnotes.txt => footnotes_linebreaks_false.txt} (100%) rename test/references/manual_footnotes/{footnotes.typ.txt => footnotes_linebreaks_false.typ.txt} (65%) create mode 100644 test/references/manual_footnotes/footnotes_linebreaks_true.docx.txt create mode 100644 test/references/manual_footnotes/footnotes_linebreaks_true.latex.txt create mode 100644 test/references/manual_footnotes/footnotes_linebreaks_true.txt create mode 100644 test/references/manual_footnotes/footnotes_linebreaks_true.typ.txt diff --git a/test/references/annotations/annotated_float.latex.txt b/test/references/annotations/annotated_float.latex.txt index 4310bfd..634a875 100644 --- a/test/references/annotations/annotated_float.latex.txt +++ b/test/references/annotations/annotated_float.latex.txt @@ -12,7 +12,7 @@ 0.124\tnote{A} \\ \bottomrule \end{tabular} -\begin{tablenotes}[flushleft,para] +\begin{tablenotes}[flushleft] \footnotesize \item[A]Note 1 \end{tablenotes} diff --git a/test/references/annotations/annotated_float.typ.txt b/test/references/annotations/annotated_float.typ.txt index 971a818..b0a5ae9 100644 --- a/test/references/annotations/annotated_float.typ.txt +++ b/test/references/annotations/annotated_float.typ.txt @@ -8,5 +8,7 @@ table.hline(y: 0, stroke: 1pt), [0.124#super[A]], table.hline(y: 1, stroke: 1pt), - table.cell(align: left, colspan: 1)[#super[A]#text(size: 0.8em)[Note 1]], + table.cell(align: left, colspan: 1)[#text(size: 0.8em)[ + #super[A]Note 1 + ]], ) diff --git a/test/references/annotations/automatic_annotations.docx.txt b/test/references/annotations/automatic_annotations.docx.txt index 897c02a..58f4d56 100644 --- a/test/references/annotations/automatic_annotations.docx.txt +++ b/test/references/annotations/automatic_annotations.docx.txt @@ -326,7 +326,7 @@ - + @@ -343,7 +343,7 @@ - + diff --git a/test/references/annotations/automatic_annotations.latex.txt b/test/references/annotations/automatic_annotations.latex.txt index aa70845..d5bd599 100644 --- a/test/references/annotations/automatic_annotations.latex.txt +++ b/test/references/annotations/automatic_annotations.latex.txt @@ -13,7 +13,7 @@ A\tnote{1} & B\tnote{2} \\ C\tnote{3} & D\tnote{1} \\ \bottomrule \end{tabular} -\begin{tablenotes}[flushleft,para] +\begin{tablenotes}[flushleft] \footnotesize \item[1]Note 1 \item[2]Note 2 diff --git a/test/references/annotations/automatic_annotations.txt b/test/references/annotations/automatic_annotations.txt index 8001c2d..0214793 100644 --- a/test/references/annotations/automatic_annotations.txt +++ b/test/references/annotations/automatic_annotations.txt @@ -1,6 +1,6 @@ - +
@@ -38,5 +38,5 @@ - +
D1
1 Note 1    2 Note 2    3 Note 3
1 Note 1
2 Note 2
3 Note 3
\ No newline at end of file diff --git a/test/references/annotations/automatic_annotations.typ.txt b/test/references/annotations/automatic_annotations.typ.txt index a2cdf43..0eb3ff2 100644 --- a/test/references/annotations/automatic_annotations.typ.txt +++ b/test/references/annotations/automatic_annotations.typ.txt @@ -11,5 +11,9 @@ [C#super[3]], [D#super[1]], table.hline(y: 2, stroke: 1pt), - table.cell(align: left, colspan: 2)[#super[1]#text(size: 0.8em)[Note 1]#h(1.5em, weak: true)#super[2]#text(size: 0.8em)[Note 2]#h(1.5em, weak: true)#super[3]#text(size: 0.8em)[Note 3]], + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[ + #super[1]Note 1\ + #super[2]Note 2\ + #super[3]Note 3 + ]], ) diff --git a/test/references/annotations/manual_annotations.docx.txt b/test/references/annotations/manual_annotations.docx.txt index 1935603..74a3124 100644 --- a/test/references/annotations/manual_annotations.docx.txt +++ b/test/references/annotations/manual_annotations.docx.txt @@ -326,7 +326,7 @@
- + @@ -343,7 +343,7 @@ - + @@ -360,7 +360,7 @@ - + diff --git a/test/references/annotations/manual_annotations.latex.txt b/test/references/annotations/manual_annotations.latex.txt index 57aeebd..28f5a57 100644 --- a/test/references/annotations/manual_annotations.latex.txt +++ b/test/references/annotations/manual_annotations.latex.txt @@ -13,7 +13,7 @@ A\tnote{X} & B\tnote{Y} \\ C\tnote{1} & D\tnote{2} \\ \bottomrule \end{tabular} -\begin{tablenotes}[flushleft,para] +\begin{tablenotes}[flushleft] \footnotesize \item[1]Note 3 \item[2]Note 4 diff --git a/test/references/annotations/manual_annotations.txt b/test/references/annotations/manual_annotations.txt index f7ed7a5..4c36fa7 100644 --- a/test/references/annotations/manual_annotations.txt +++ b/test/references/annotations/manual_annotations.txt @@ -1,6 +1,6 @@ - +
@@ -38,5 +38,5 @@ - +
D2
1 Note 3    2 Note 4    X Note 1    Y Note 2
1 Note 3
2 Note 4
X Note 1
Y Note 2
\ No newline at end of file diff --git a/test/references/annotations/manual_annotations.typ.txt b/test/references/annotations/manual_annotations.typ.txt index 9c69685..2f0da34 100644 --- a/test/references/annotations/manual_annotations.typ.txt +++ b/test/references/annotations/manual_annotations.typ.txt @@ -11,5 +11,10 @@ [C#super[1]], [D#super[2]], table.hline(y: 2, stroke: 1pt), - table.cell(align: left, colspan: 2)[#super[1]#text(size: 0.8em)[Note 3]#h(1.5em, weak: true)#super[2]#text(size: 0.8em)[Note 4]#h(1.5em, weak: true)#super[X]#text(size: 0.8em)[Note 1]#h(1.5em, weak: true)#super[Y]#text(size: 0.8em)[Note 2]], + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[ + #super[1]Note 3\ + #super[2]Note 4\ + #super[X]Note 1\ + #super[Y]Note 2 + ]], ) diff --git a/test/references/manual_footnotes/footnotes_and_annotated.docx.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.docx.txt similarity index 100% rename from test/references/manual_footnotes/footnotes_and_annotated.docx.txt rename to test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.docx.txt diff --git a/test/references/manual_footnotes/footnotes_and_annotated.latex.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.latex.txt similarity index 100% rename from test/references/manual_footnotes/footnotes_and_annotated.latex.txt rename to test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.latex.txt diff --git a/test/references/manual_footnotes/footnotes_and_annotated.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.txt similarity index 100% rename from test/references/manual_footnotes/footnotes_and_annotated.txt rename to test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.txt diff --git a/test/references/manual_footnotes/footnotes_and_annotated.typ.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.typ.txt similarity index 59% rename from test/references/manual_footnotes/footnotes_and_annotated.typ.txt rename to test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.typ.txt index ba2678e..779b58d 100644 --- a/test/references/manual_footnotes/footnotes_and_annotated.typ.txt +++ b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_false.typ.txt @@ -9,5 +9,5 @@ [Cell 1#super[1]], [Cell 2], table.hline(y: 1, stroke: 1pt), - table.cell(align: left, colspan: 2)[#super[1]#text(size: 0.8em)[Note 1]#h(1.5em, weak: true)First footnote.#h(1.5em, weak: true)Second footnote.], + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[#super[1]Note 1#h(1.5em, weak: true)First footnote.#h(1.5em, weak: true)Second footnote.]], ) diff --git a/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.docx.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.docx.txt new file mode 100644 index 0000000..d09dcec --- /dev/null +++ b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.docx.txt @@ -0,0 +1,302 @@ +############################## [Content_Types].xml ############################## + + + + + + + + + +############################## _rels/.rels ############################## + + + + +############################## word/_rels/document.xml.rels ############################## + + + + +############################## word/styles.xml ############################## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +############################## word/document.xml ############################## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cell 1 + + + + + + 1 + + + + + + + + + + + + + + + Cell 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + Note 1 + + + + + + + + + + First footnote. + + + + + + + + + + Second footnote. + + + + + + + + diff --git a/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.latex.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.latex.txt new file mode 100644 index 0000000..95b488e --- /dev/null +++ b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.latex.txt @@ -0,0 +1,23 @@ +\documentclass{article} +\usepackage{threeparttable} +\usepackage{multirow} +\usepackage{booktabs} +\begin{document} +\begin{table}[!ht] +\setlength\tabcolsep{0pt} +\centering +\begin{threeparttable} +\begin{tabular}{@{\extracolsep{2ex}}*{2}{cc}} +\toprule +Cell 1\tnote{1} & Cell 2 \\ +\bottomrule +\end{tabular} +\begin{tablenotes}[flushleft] +\footnotesize +\item[1]Note 1 +\item[]First footnote. +\item[]Second footnote. +\end{tablenotes} +\end{threeparttable} +\end{table} +\end{document} \ No newline at end of file diff --git a/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.txt new file mode 100644 index 0000000..b8c11b0 --- /dev/null +++ b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.txt @@ -0,0 +1,38 @@ + + + + + + + + + +
Cell 11Cell 2
1 Note 1
First footnote.
Second footnote.
\ No newline at end of file diff --git a/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.typ.txt b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.typ.txt new file mode 100644 index 0000000..7a741cf --- /dev/null +++ b/test/references/manual_footnotes/footnotes_and_annotated_linebreaks_true.typ.txt @@ -0,0 +1,17 @@ + +#table( + rows: 1, + columns: 2, + column-gutter: 0.25em, + align: (center, center), + stroke: none, + table.hline(y: 0, stroke: 1pt), + [Cell 1#super[1]], + [Cell 2], + table.hline(y: 1, stroke: 1pt), + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[ + #super[1]Note 1\ + First footnote.\ + Second footnote. + ]], +) diff --git a/test/references/manual_footnotes/footnotes.docx.txt b/test/references/manual_footnotes/footnotes_linebreaks_false.docx.txt similarity index 100% rename from test/references/manual_footnotes/footnotes.docx.txt rename to test/references/manual_footnotes/footnotes_linebreaks_false.docx.txt diff --git a/test/references/manual_footnotes/footnotes.latex.txt b/test/references/manual_footnotes/footnotes_linebreaks_false.latex.txt similarity index 100% rename from test/references/manual_footnotes/footnotes.latex.txt rename to test/references/manual_footnotes/footnotes_linebreaks_false.latex.txt diff --git a/test/references/manual_footnotes/footnotes.txt b/test/references/manual_footnotes/footnotes_linebreaks_false.txt similarity index 100% rename from test/references/manual_footnotes/footnotes.txt rename to test/references/manual_footnotes/footnotes_linebreaks_false.txt diff --git a/test/references/manual_footnotes/footnotes.typ.txt b/test/references/manual_footnotes/footnotes_linebreaks_false.typ.txt similarity index 65% rename from test/references/manual_footnotes/footnotes.typ.txt rename to test/references/manual_footnotes/footnotes_linebreaks_false.typ.txt index bea14b4..f5aa1e5 100644 --- a/test/references/manual_footnotes/footnotes.typ.txt +++ b/test/references/manual_footnotes/footnotes_linebreaks_false.typ.txt @@ -9,5 +9,5 @@ [Cell 1], [Cell 2], table.hline(y: 1, stroke: 1pt), - table.cell(align: left, colspan: 2)[First footnote.#h(1.5em, weak: true)Second footnote.], + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[First footnote.#h(1.5em, weak: true)Second footnote.]], ) diff --git a/test/references/manual_footnotes/footnotes_linebreaks_true.docx.txt b/test/references/manual_footnotes/footnotes_linebreaks_true.docx.txt new file mode 100644 index 0000000..9192e3b --- /dev/null +++ b/test/references/manual_footnotes/footnotes_linebreaks_true.docx.txt @@ -0,0 +1,279 @@ +############################## [Content_Types].xml ############################## + + + + + + + + + +############################## _rels/.rels ############################## + + + + +############################## word/_rels/document.xml.rels ############################## + + + + +############################## word/styles.xml ############################## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +############################## word/document.xml ############################## + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cell 1 + + + + + + + + + + + + + + + Cell 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + First footnote. + + + + + + + + + + Second footnote. + + + + + + + + diff --git a/test/references/manual_footnotes/footnotes_linebreaks_true.latex.txt b/test/references/manual_footnotes/footnotes_linebreaks_true.latex.txt new file mode 100644 index 0000000..541eb80 --- /dev/null +++ b/test/references/manual_footnotes/footnotes_linebreaks_true.latex.txt @@ -0,0 +1,22 @@ +\documentclass{article} +\usepackage{threeparttable} +\usepackage{multirow} +\usepackage{booktabs} +\begin{document} +\begin{table}[!ht] +\setlength\tabcolsep{0pt} +\centering +\begin{threeparttable} +\begin{tabular}{@{\extracolsep{2ex}}*{2}{cc}} +\toprule +Cell 1 & Cell 2 \\ +\bottomrule +\end{tabular} +\begin{tablenotes}[flushleft] +\footnotesize +\item[]First footnote. +\item[]Second footnote. +\end{tablenotes} +\end{threeparttable} +\end{table} +\end{document} \ No newline at end of file diff --git a/test/references/manual_footnotes/footnotes_linebreaks_true.txt b/test/references/manual_footnotes/footnotes_linebreaks_true.txt new file mode 100644 index 0000000..d3bd79b --- /dev/null +++ b/test/references/manual_footnotes/footnotes_linebreaks_true.txt @@ -0,0 +1,38 @@ + + + + + + + + + +
Cell 1Cell 2
First footnote.
Second footnote.
\ No newline at end of file diff --git a/test/references/manual_footnotes/footnotes_linebreaks_true.typ.txt b/test/references/manual_footnotes/footnotes_linebreaks_true.typ.txt new file mode 100644 index 0000000..3df5201 --- /dev/null +++ b/test/references/manual_footnotes/footnotes_linebreaks_true.typ.txt @@ -0,0 +1,16 @@ + +#table( + rows: 1, + columns: 2, + column-gutter: 0.25em, + align: (center, center), + stroke: none, + table.hline(y: 0, stroke: 1pt), + [Cell 1], + [Cell 2], + table.hline(y: 1, stroke: 1pt), + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[ + First footnote.\ + Second footnote. + ]], +) diff --git a/test/references/merged_cells/custom_datatypes.latex.txt b/test/references/merged_cells/custom_datatypes.latex.txt index 10676a8..60aa9cf 100644 --- a/test/references/merged_cells/custom_datatypes.latex.txt +++ b/test/references/merged_cells/custom_datatypes.latex.txt @@ -16,7 +16,7 @@ \multicolumn{2}{c}{Label\tnote{1}} \\ \bottomrule \end{tabular} -\begin{tablenotes}[flushleft,para] +\begin{tablenotes}[flushleft] \footnotesize \item[1]Annotation \end{tablenotes} diff --git a/test/references/merged_cells/custom_datatypes.typ.txt b/test/references/merged_cells/custom_datatypes.typ.txt index d2e7dc2..298d04e 100644 --- a/test/references/merged_cells/custom_datatypes.typ.txt +++ b/test/references/merged_cells/custom_datatypes.typ.txt @@ -12,5 +12,7 @@ table.cell(colspan: 2)[AB], table.cell(colspan: 2)[Label#super[1]], table.hline(y: 5, stroke: 1pt), - table.cell(align: left, colspan: 2)[#super[1]#text(size: 0.8em)[Annotation]], + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[ + #super[1]Annotation + ]], ) diff --git a/test/references/replace/replacemissing_default.latex.txt b/test/references/replace/replacemissing_default.latex.txt index 5ae42c2..52d0dad 100644 --- a/test/references/replace/replacemissing_default.latex.txt +++ b/test/references/replace/replacemissing_default.latex.txt @@ -13,7 +13,7 @@ 1 & 2 \\ \bottomrule \end{tabular} -\begin{tablenotes}[flushleft,para] +\begin{tablenotes}[flushleft] \footnotesize - No value \end{tablenotes} diff --git a/test/references/replace/replacemissing_default.typ.txt b/test/references/replace/replacemissing_default.typ.txt index e918d28..12fa84b 100644 --- a/test/references/replace/replacemissing_default.typ.txt +++ b/test/references/replace/replacemissing_default.typ.txt @@ -11,5 +11,7 @@ [1], [2], table.hline(y: 2, stroke: 1pt), - table.cell(align: left, colspan: 2)[#text(size: 0.8em)[- No value]], + table.cell(align: left, colspan: 2)[#text(size: 0.8em)[ + - No value + ]], ) diff --git a/test/references/table_one/all_missing_group.latex.txt b/test/references/table_one/all_missing_group.latex.txt index 6f20de5..62e3885 100644 --- a/test/references/table_one/all_missing_group.latex.txt +++ b/test/references/table_one/all_missing_group.latex.txt @@ -19,7 +19,7 @@ \hspace{12.0pt}Missing & 3 (50\%) & 3 (100\%) & 0 (0\%) \\ \bottomrule \end{tabular} -\begin{tablenotes}[flushleft,para] +\begin{tablenotes}[flushleft] \footnotesize NC - Not computable \end{tablenotes} diff --git a/test/references/table_one/all_missing_group.typ.txt b/test/references/table_one/all_missing_group.typ.txt index 91cc64a..1599546 100644 --- a/test/references/table_one/all_missing_group.typ.txt +++ b/test/references/table_one/all_missing_group.typ.txt @@ -32,5 +32,7 @@ [3 (100%)], [0 (0%)], table.hline(y: 6, stroke: 1pt), - table.cell(colspan: 4)[#text(size: 0.8em)[NC - Not computable]], + table.cell(colspan: 4)[#text(size: 0.8em)[ + NC - Not computable + ]], ) From 3d3455f39920e66b38ee8cc45fe9d07622be09bb Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 10:00:10 +0200 Subject: [PATCH 09/12] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d669e4a..04fa022 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- **Breaking** Footnotes are by default separated with linebreaks now. This can be changed by setting the new `Table` option `linebreak_footnotes = false` [#34](https://github.com/PumasAI/SummaryTables.jl/pull/34). - **Breaking** Changed `show_overall` keyword of `table_one` to `show_total`. The name of all total columns was changed from `"Overall"` to `"Total"` as well but this can be changed using the new `total_name` keyword. - Added ability to show "Total" statistics for subgroups in `table_one` [#30](https://github.com/PumasAI/SummaryTables.jl/pull/30). - Fixed tagging of header rows in docx output, such that the header section is now repeated across pages as expected [#32](https://github.com/PumasAI/SummaryTables.jl/pull/32). From ef76ed14a5bf4b7d68dcb13077bf8010afb9960c Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 10:09:01 +0200 Subject: [PATCH 10/12] fix latex bug --- src/latex.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/latex.jl b/src/latex.jl index aa47758..be48f2e 100644 --- a/src/latex.jl +++ b/src/latex.jl @@ -125,6 +125,8 @@ function Base.show(io::IO, ::MIME"text/latex", ct::Table) print(io, raw"\item[") _showas(io, MIME"text/latex"(), label) print(io, "]") + else + print(io, raw"\item[]") end _showas(io, MIME"text/latex"(), annotation) println(io) From 3de6bacb64fcb1c676bfcecbca49cee431abe80b Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 10:10:41 +0200 Subject: [PATCH 11/12] update refs --- test/references/replace/replacemissing_default.latex.txt | 2 +- test/references/table_one/all_missing_group.latex.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/references/replace/replacemissing_default.latex.txt b/test/references/replace/replacemissing_default.latex.txt index 52d0dad..9efb22b 100644 --- a/test/references/replace/replacemissing_default.latex.txt +++ b/test/references/replace/replacemissing_default.latex.txt @@ -15,7 +15,7 @@ \end{tabular} \begin{tablenotes}[flushleft] \footnotesize -- No value +\item[]- No value \end{tablenotes} \end{threeparttable} \end{table} diff --git a/test/references/table_one/all_missing_group.latex.txt b/test/references/table_one/all_missing_group.latex.txt index 62e3885..d433b31 100644 --- a/test/references/table_one/all_missing_group.latex.txt +++ b/test/references/table_one/all_missing_group.latex.txt @@ -21,7 +21,7 @@ \end{tabular} \begin{tablenotes}[flushleft] \footnotesize -NC - Not computable +\item[]NC - Not computable \end{tablenotes} \end{threeparttable} \end{table} From c485034482f326d6ec77ada4dbb4a4ee8272adc8 Mon Sep 17 00:00:00 2001 From: Julius Krumbiegel Date: Mon, 23 Sep 2024 10:20:01 +0200 Subject: [PATCH 12/12] update readme svg --- .../figure-commonmark/cell-5-output-1.svg | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/README_files/figure-commonmark/cell-5-output-1.svg b/README_files/figure-commonmark/cell-5-output-1.svg index 40d99f6..ab4f6c4 100644 --- a/README_files/figure-commonmark/cell-5-output-1.svg +++ b/README_files/figure-commonmark/cell-5-output-1.svg @@ -1,7 +1,7 @@ - + - + @@ -300,26 +300,22 @@ - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -508,7 +504,7 @@ - +