I'll ask my question here since I think it has more to do with LaTeX than stackoverflow. I am using R Markdown with LaTeX to create pdf documents that shows some tables. Using the R language with Markdown and LaTeX is a bit tricky. I currently want to display a table similar to this one :
Age Womens Mens Total
1: [20,30) 179,0 (2,4) 118,0 (2,0) 297,0 (2,2)
2: [30,40) 2 325,0 (30,9) 2 115,0 (35,4) 4 440,0 (32,9)
3: [40,80) 1 814,0 (24,1) 1 610,0 (26,9) 3 424,0 (25,4)
...
The LaTeX version of this table have the booktabs and striped options.
The problem is that when I knitr (run the code), [
is causing the following error :
! Paragraph ended before \CT@rowd was complete. \par
I know this is the problem since when I changes [
by (
I got no problem and my table is showing up without any problems but I have to use it for this document [
.
The R package I use for LaTeX is kableExtra
which convert my table into LaTeX code (which gives an error), the code with a problem is :
\begin{table}[!h]
\centering
\begin{tabular}{llll}
\toprule
Age & Womens & Mens & Total\\
\midrule
\rowcolor{gray!6} [65,70) & 179,0 (2,4) & 118,0 (2,0) & 297,0 (2,2)\\
[70,75) & 2 325,0 (30,9) & 2 115,0 (35,4) & 4 440,0 (32,9)\\
\rowcolor{gray!6} [75,80) & 1 814,0 (24,1) & 1 610,0 (26,9) & 3 424,0 (25,4)\\
[80,85) & 1 226,0 (16,3) & 939,0 (15,7) & 2 165,0 (16,0)\\
\rowcolor{gray!6} [85,90) & 1 033,0 (13,7) & 745,0 (12,5) & 1 778,0 (13,2)\\
\addlinespace
[90,95) & 609,0 (8,1) & 343,0 (5,7) & 952,0 (7,1)\\
\rowcolor{gray!6} [95,100) & 253,0 (3,4) & 96,0 (1,6) & 349,0 (2,6)\\
[100,109) & 82,0 (1,1) & 15,0 (0,3) & 97,0 (0,7)\\
\rowcolor{gray!6} Total & 7 521,0 (100,0) & 5 981,0 (100,0) & 13 502,0 (100,0)\\
\bottomrule
\end{tabular}
\end{table}
Anyone knows why [
isn't making my table displaying? I already searched here and on stack without finding similar questions. Also [
doesn't seems to be an escaping character in LaTeX. Any help would be appreciated, thank you.
Edit :
Age Womens Mens Total
[65,70) 179,0 (2,4) 118,0 (2,0) 297,0 (2,2)
[70,75) 2 325,0 (30,9) 2 115,0 (35,4) 4 440,0 (32,9)
[75,80) 1 814,0 (24,1) 1 610,0 (26,9) 3 424,0 (25,4)
[80,85) 1 226,0 (16,3) 939,0 (15,7) 2 165,0 (16,0)
[85,90) 1 033,0 (13,7) 745,0 (12,5) 1 778,0 (13,2)
[90,95) 609,0 (8,1) 343,0 (5,7) 952,0 (7,1)
[95,100) 253,0 (3,4) 96,0 (1,6) 349,0 (2,6)
[100,109) 82,0 (1,1) 15,0 (0,3) 97,0 (0,7)
Total 7 521,0 (100,0) 5 981,0 (100,0) 13 502,0 (100,0)