I am attempting to output a latex table using r markdown, kable and kableExtra. I get an error in the table rendering code that is not part of the latex code produced by R.
The code:
outTab <- m.OutTab %>%
kable(format='latex', booktabs=T ,
#caption = "Population Trend",
digits=1,
row.names=FALSE,
align='lccccc',
col.names = names_spaced,
escape = FALSE)
where "m.OutTab" is an matrix that contains the table to be rendered,
The error:
Error producing PDF.
! Misplaced \noalign.
\addlinespace ->\noalign
{\ifnum 0=`}\fi \@ifnextchar [{\@addspace }{\@addsp...
l.116 \addlinespace
Error: pandoc document conversion failed with error 43
These codes ("\noalign ...") is not part of "outTab".
Any idea how to work around this error?
If you are using bookdown, this could be caused by using non-alphanumeric characters in your code chunk label. I had a similar problem which was solved by removing an underscore.
I have encountered this problem. I seem to be able to fix it by specifying format="pandoc" or format="markdown". If seems to be some issue with how latex output from kable is handled.
It seems like this question is getting a lot of traffic. If you see an error like that, that means that there are something wrong with the raw latex you wrote. Check special symbols like < \ / [] and make sure they are properly escaped by yourself.
Due to running mechanism, a lot of places with kableExtra requires double escape, which means that you need to type \\\\
to get a \
. You should be able to get it work after a few attempts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With