[Tex/LaTex] kable_styling for alternative row colors in Rmarkdown

colormarkdownpdftexr

I'm trying to use kable and kableExtra to generate a table in latex document at Rmarkdown.

I have used the xcolor package in the header of .Rmd file :

header-includes: 
\usepackage{xcolor} 

but when I use latex_options = "striped" in kable_styling

I'm getting the error :

knitr::kable(cbind(main()$AEP),format = "latex",booktabs = T)%>%
kable_styling(latex_options="striped",position = "center",full_width = F)

Warning: running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS report.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output report.pdf --template "C:\Users\ali.hadjihosseini\Documents\R\win-library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"' had status 43
Warning: Error in : pandoc document conversion failed with error 43
Stack trace (innermost first):
    53: pandoc_convert
    52: convert
    51: render
    50: download$func [C:\Users\ali\Desktop\dashbord\/server.R#1164]
     1: runApp
Error : pandoc document conversion failed with error 43

If I don't use that latex_options="striped", everything is fine ! Can anybody tell me what is wrong here ?

Best Answer

kableExtra load \usepackage[table]{xcolor} automatically. It means that if you load \usepackage{xcolor}, there will be a conflict in xcolor options.

You can read more in the "LaTeX packages used in this package" section of the vignette. https://cran.r-project.org/web/packages/kableExtra/vignettes/awesome_table_in_pdf.pdf