Skip to content

Commit cdde460

Browse files
committed
Updated tests for kable() in LaTeX mode typesetting numeric columns in math mode. Improves #1709.
1 parent c37fbd6 commit cdde460

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
@@ -39,9 +39,22 @@ assert('kable() does not add extra spaces to character columns', {
3939
\\hline
4040
x & y\\\\
4141
\\hline
42-
1.20 & fooooo\\\\
42+
\\(1.20\\) & fooooo\\\\
4343
\\hline
44-
4.87 & bar\\\\
44+
\\(4.87\\) & bar\\\\
45+
\\hline
46+
\\end{tabular}'
47+
})
48+
49+
assert('kable() in LaTeX mode formats minus signs and decimal and thousands separators correctly', {
50+
kable2(data.frame(x = c(-1111, 2222), y = c(1111, -0.5), z = c('text,comma', '-0.5')), 'latex', format.arg=list(big.mark = ',')) %==% '
51+
\\begin{tabular}{r|r|l}
52+
\\hline
53+
x & y & z\\\\
54+
\\hline
55+
\\(-1{,}111\\) & \\(1{,}111.0\\) & text,comma\\\\
56+
\\hline
57+
\\(2{,}222\\) & \\(-0.5\\) & -0.5\\\\
4558
\\hline
4659
\\end{tabular}'
4760
})
@@ -86,11 +99,11 @@ assert('kable(format = "latex", linesep = ...) works', {
8699
\\hline
87100
x\\\\
88101
\\hline
89-
1\\\\
90-
2\\\\
91-
3\\\\
102+
\\(1\\)\\\\
103+
\\(2\\)\\\\
104+
\\(3\\)\\\\
92105
\\midrule
93-
4\\\\
106+
\\(4\\)\\\\
94107
\\hline
95108
\\end{tabular}"
96109
})

0 commit comments

Comments
 (0)