From 5994167bba9d73d96f13d5c3bf9102e71c05d5a6 Mon Sep 17 00:00:00 2001 From: Isaac Wheeler Date: Fri, 5 Sep 2025 15:10:29 -0400 Subject: [PATCH 1/4] Swap ; for , in LatexifyExt and matching tests --- ext/LatexifyExt.jl | 6 +++--- test/runtests.jl | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ext/LatexifyExt.jl b/ext/LatexifyExt.jl index f8eec814..aec1a3ff 100644 --- a/ext/LatexifyExt.jl +++ b/ext/LatexifyExt.jl @@ -193,7 +193,7 @@ function _transform(q::AbstractQuantity, ::AbstractNumberFormatter) Expr( :latexifymerge, NakedNumber(q.val), - has_unit_spacing(unit(q)) ? "\\;" : nothing, + has_unit_spacing(unit(q)) ? "\\," : nothing, NakedUnits(unit(q)), ) end @@ -243,7 +243,7 @@ end ) end env --> :inline - return Expr(:latexifymerge, q.val, "\\;\\mathrm{", unitnames[(:mathrm, unitname)], "}") + return Expr(:latexifymerge, q.val, "\\,\\mathrm{", unitnames[(:mathrm, unitname)], "}") end # arrays ------------------------- @@ -253,7 +253,7 @@ end # Array of quantities with the same unit env --> :equation return Expr( - :latexifymerge, ustrip.(a), has_unit_spacing(first(a)) ? "\\;" : "", unit(first(a)) + :latexifymerge, ustrip.(a), has_unit_spacing(first(a)) ? "\\," : "", unit(first(a)) ) end diff --git a/test/runtests.jl b/test/runtests.jl index c0e560f3..74dc8d63 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1793,7 +1793,7 @@ end ) unitfullatexifytest( 24.7e9u"Gm/s^2", - raw"$2.47 \cdot 10^{10}\;\mathrm{Gm}\,\mathrm{s}^{-2}$", + raw"$2.47 \cdot 10^{10}\,\mathrm{Gm}\,\mathrm{s}^{-2}$", raw"\qty{2.47e10}{\giga\meter\per\second\tothe{2}}", raw"\qty{2.47e10}{Gm.s^{-2}}", ) @@ -1801,7 +1801,7 @@ end u"percent", raw"$\mathrm{\%}$", raw"\unit{\percent}", raw"\unit{\%}" ) unitfullatexifytest( - 2u"°C", raw"$2\;\mathrm{^\circ C}$", raw"\qty{2}{\celsius}", raw"\qty{2}{\celsius}" + 2u"°C", raw"$2\,\mathrm{^\circ C}$", raw"\qty{2}{\celsius}", raw"\qty{2}{\celsius}" ) unitfullatexifytest( 1u"°", raw"$1\mathrm{^{\circ}}$", raw"\qty{1}{\degree}", raw"\qty{1}{\degree}" @@ -1816,7 +1816,7 @@ end 2 \\ 3 \\ \end{array} - \right]\;\mathrm{m} + \right]\,\mathrm{m} \end{equation} """, raw""" @@ -1827,7 +1827,7 @@ end \num{2} \\ \num{3} \\ \end{array} - \right]\;\unit{\meter} + \right]\,\unit{\meter} \end{equation} """, raw""" @@ -1838,7 +1838,7 @@ end \num{2} \\ \num{3} \\ \end{array} - \right]\;\unit{m} + \right]\,\unit{m} \end{equation} """, ) @@ -1851,7 +1851,7 @@ end 2 \\ 3 \\ \end{array} - \right]\;\mathrm{m} + \right]\,\mathrm{m} \end{equation} """, raw"\qtylist{1;2;3}{\meter}", @@ -1859,7 +1859,7 @@ end ) @test latexify(24.7e9u"Gm/s^2"; fmt="%.1e") == - L"$2.5e+10\;\mathrm{Gm}\,\mathrm{s}^{-2}$" + L"$2.5e+10\,\mathrm{Gm}\,\mathrm{s}^{-2}$" @test latexify(5.9722e24u"kg"; fmt=SiunitxNumberFormatter(version=2)) == raw"\SI{5.9722e24}{\kilo\gram}" @test latexify(u"eV"; fmt=SiunitxNumberFormatter(version=2)) == raw"\si{\electronvolt}" @@ -1868,16 +1868,16 @@ end @testset "permode" begin p = 5u"m^3*s^2/H/kg^4" @test latexify(p) == LaTeXString( - raw"$5\;\mathrm{m}^{3}\,\mathrm{s}^{2}\,\mathrm{kg}^{-4}\,\mathrm{H}^{-1}$" + raw"$5\,\mathrm{m}^{3}\,\mathrm{s}^{2}\,\mathrm{kg}^{-4}\,\mathrm{H}^{-1}$" ) @test latexify(p; permode=:power) == LaTeXString( - raw"$5\;\mathrm{m}^{3}\,\mathrm{s}^{2}\,\mathrm{kg}^{-4}\,\mathrm{H}^{-1}$" + raw"$5\,\mathrm{m}^{3}\,\mathrm{s}^{2}\,\mathrm{kg}^{-4}\,\mathrm{H}^{-1}$" ) @test latexify(p; permode=:slash) == LaTeXString( - raw"$5\;\mathrm{m}^{3}\,\mathrm{s}^{2}\,/\,\mathrm{kg}^{4}\,\mathrm{H}$" + raw"$5\,\mathrm{m}^{3}\,\mathrm{s}^{2}\,/\,\mathrm{kg}^{4}\,\mathrm{H}$" ) @test latexify(p; permode=:frac) == LaTeXString( - raw"$5\;\frac{\mathrm{m}^{3}\,\mathrm{s}^{2}}{\mathrm{kg}^{4}\,\mathrm{H}}$" + raw"$5\,\frac{\mathrm{m}^{3}\,\mathrm{s}^{2}}{\mathrm{kg}^{4}\,\mathrm{H}}$" ) @test latexify(p; permode=:frac, fmt=SiunitxNumberFormatter()) == latexify(p; fmt=SiunitxNumberFormatter()) @@ -1899,7 +1899,7 @@ end @testset "Parentheses" begin @test @latexify($(3u"mm")^2 - 4 * $(2u"mm^2")) == - raw"$\left( 3\;\mathrm{mm} \right)^{2} - 4 \cdot 2\;\mathrm{mm}^{2}$" + raw"$\left( 3\,\mathrm{mm} \right)^{2} - 4 \cdot 2\,\mathrm{mm}^{2}$" end end From 8d0cbd89fba216fa5c84b8eb22dbbd3130722ac6 Mon Sep 17 00:00:00 2001 From: Isaac Wheeler Date: Fri, 5 Sep 2025 15:31:28 -0400 Subject: [PATCH 2/4] Take out extra space after array --- ext/LatexifyExt.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/LatexifyExt.jl b/ext/LatexifyExt.jl index aec1a3ff..2c0d1233 100644 --- a/ext/LatexifyExt.jl +++ b/ext/LatexifyExt.jl @@ -253,7 +253,7 @@ end # Array of quantities with the same unit env --> :equation return Expr( - :latexifymerge, ustrip.(a), has_unit_spacing(first(a)) ? "\\," : "", unit(first(a)) + :latexifymerge, ustrip.(a), unit(first(a)) ) end From 29c2a023e8fdf82b2f59fb0fb1fda2ccc09dff23 Mon Sep 17 00:00:00 2001 From: Isaac Wheeler Date: Fri, 5 Sep 2025 15:36:42 -0400 Subject: [PATCH 3/4] Match no-spacing in arrays for tests --- test/runtests.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 74dc8d63..2a8f52c2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1816,7 +1816,7 @@ end 2 \\ 3 \\ \end{array} - \right]\,\mathrm{m} + \right]\mathrm{m} \end{equation} """, raw""" @@ -1827,7 +1827,7 @@ end \num{2} \\ \num{3} \\ \end{array} - \right]\,\unit{\meter} + \right]\unit{\meter} \end{equation} """, raw""" @@ -1838,7 +1838,7 @@ end \num{2} \\ \num{3} \\ \end{array} - \right]\,\unit{m} + \right]\unit{m} \end{equation} """, ) @@ -1851,7 +1851,7 @@ end 2 \\ 3 \\ \end{array} - \right]\,\mathrm{m} + \right]\mathrm{m} \end{equation} """, raw"\qtylist{1;2;3}{\meter}", From cb6bdbfc277fe5e6382f8ad031c78e825b77a75d Mon Sep 17 00:00:00 2001 From: Isaac Wheeler Date: Mon, 15 Sep 2025 10:15:00 -0400 Subject: [PATCH 4/4] Put thin space back between array and unit --- ext/LatexifyExt.jl | 2 +- test/runtests.jl | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/LatexifyExt.jl b/ext/LatexifyExt.jl index 2c0d1233..aec1a3ff 100644 --- a/ext/LatexifyExt.jl +++ b/ext/LatexifyExt.jl @@ -253,7 +253,7 @@ end # Array of quantities with the same unit env --> :equation return Expr( - :latexifymerge, ustrip.(a), unit(first(a)) + :latexifymerge, ustrip.(a), has_unit_spacing(first(a)) ? "\\," : "", unit(first(a)) ) end diff --git a/test/runtests.jl b/test/runtests.jl index 2a8f52c2..74dc8d63 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1816,7 +1816,7 @@ end 2 \\ 3 \\ \end{array} - \right]\mathrm{m} + \right]\,\mathrm{m} \end{equation} """, raw""" @@ -1827,7 +1827,7 @@ end \num{2} \\ \num{3} \\ \end{array} - \right]\unit{\meter} + \right]\,\unit{\meter} \end{equation} """, raw""" @@ -1838,7 +1838,7 @@ end \num{2} \\ \num{3} \\ \end{array} - \right]\unit{m} + \right]\,\unit{m} \end{equation} """, ) @@ -1851,7 +1851,7 @@ end 2 \\ 3 \\ \end{array} - \right]\mathrm{m} + \right]\,\mathrm{m} \end{equation} """, raw"\qtylist{1;2;3}{\meter}",