title: Rendering Table with conditional color in latex as a pdf document with rownames = TRUE (rmarkdown, kable and kableExtra )
body: <p>I am attempting to output a latex table using r markdown, kable and kableExtra. When i use the option row.names=FALSE instead of row.names=TRUE the latex code generates \vphantom code which produce an error to create the pdf .
  It seems the problem is linked to the row_spec option.</p>
  
  <p>Here is  Rmarkdown code (.Rmd File):</p>
  
  <pre><code>---
  title: "Test"
  output:
  pdf_document: 
  fig_caption: true
  keep_tex: true
  ---
  
  {r setup, include=FALSE}
  knitr::opts_chunk$set(echo = FALSE)
  
  
  {r}
  library(knitr)
  library(kableExtra)
  
  temp &lt;- mtcars[1:5,1:5]
  
  kable(temp, format = "latex", booktabs = F,row.names=F)  %&gt;%
  kable_styling(position = "center") %&gt;%
  row_spec(1, bold = T, background = "red")
  </code></pre>
  
  <p>The error is :</p>
  
  <blockquote>
    <p>! Forbidden control sequence found while scanning use of
    \check@nocorr@.  
                    \par  l.105 ...color{red}  \textbf{21.0 &amp;\vphantom{1} 6}
                                                       &amp; \textbf{160} &amp; \textbf{...</p>
  </blockquote>
  
  <p>Do you have any issue of what is happening ?</p>