From 8aa000efd08112681883770e7b9a6a3ff6eaa84b Mon Sep 17 00:00:00 2001
From: "Pavel N. Krivitsky"
Date: Thu, 21 May 2020 08:03:54 +1000
Subject: [PATCH] Updated tests for kable() in LaTeX mode typesetting numeric
columns in math mode. Improves yihui#1709.
---
tests/testit/test-table.R | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tests/testit/test-table.R b/tests/testit/test-table.R
index 59713dddc1..775d648246 100644
--- a/tests/testit/test-table.R
+++ b/tests/testit/test-table.R
@@ -39,9 +39,22 @@ assert('kable() does not add extra spaces to character columns', {
\\hline
x & y\\\\
\\hline
-1.20 & fooooo\\\\
+\\(1.20\\) & fooooo\\\\
\\hline
-4.87 & bar\\\\
+\\(4.87\\) & bar\\\\
+\\hline
+\\end{tabular}'
+})
+
+assert('kable() in LaTeX mode formats minus signs and decimal and thousands separators correctly', {
+ kable2(data.frame(x = c(-1111, 2222), y = c(1111, -0.5), z = c('text,comma', '-0.5')), 'latex', format.arg=list(big.mark = ',')) %==% '
+\\begin{tabular}{r|r|l}
+\\hline
+x & y & z\\\\
+\\hline
+\\(-1{,}111\\) & \\(1{,}111.0\\) & text,comma\\\\
+\\hline
+\\(2{,}222\\) & \\(-0.5\\) & -0.5\\\\
\\hline
\\end{tabular}'
})
@@ -86,11 +99,11 @@ assert('kable(format = "latex", linesep = ...) works', {
\\hline
x\\\\
\\hline
-1\\\\
-2\\\\
-3\\\\
+\\(1\\)\\\\
+\\(2\\)\\\\
+\\(3\\)\\\\
\\midrule
-4\\\\
+\\(4\\)\\\\
\\hline
\\end{tabular}"
})