Skip to content

Commit 4fdd412

Browse files
committed
Updated tests for kable() in LaTeX mode typesetting numeric columns in math mode. Improves #1709.
1 parent 705c92b commit 4fdd412

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

tests/testit/test-table.R

+19-6
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,22 @@ assert('kable() does not add extra spaces to character columns', {
3636
\\hline
3737
x & y\\\\
3838
\\hline
39-
1.20 & fooooo\\\\
39+
\\(1.20\\) & fooooo\\\\
4040
\\hline
41-
4.87 & bar\\\\
41+
\\(4.87\\) & bar\\\\
42+
\\hline
43+
\\end{tabular}'
44+
})
45+
46+
assert('kable() in LaTeX mode formats minus signs and decimal and thousands separators correctly', {
47+
kable2(data.frame(x = c(-1111, 2222), y = c(1111, -0.5), z = c('text,comma', '-0.5')), 'latex', format.arg=list(big.mark = ',')) %==% '
48+
\\begin{tabular}{r|r|l}
49+
\\hline
50+
x & y & z\\\\
51+
\\hline
52+
\\(-1{,}111\\) & \\(1{,}111.0\\) & text,comma\\\\
53+
\\hline
54+
\\(2{,}222\\) & \\(-0.5\\) & -0.5\\\\
4255
\\hline
4356
\\end{tabular}')
4457
})
@@ -89,11 +102,11 @@ assert('kable(format = "latex", linesep = ...) works', {
89102
\\hline
90103
x\\\\
91104
\\hline
92-
1\\\\
93-
2\\\\
94-
3\\\\
105+
\\(1\\)\\\\
106+
\\(2\\)\\\\
107+
\\(3\\)\\\\
95108
\\midrule
96-
4\\\\
109+
\\(4\\)\\\\
97110
\\hline
98111
\\end{tabular}')
99112
})

0 commit comments

Comments
 (0)