title: KableExtra using row_spec in collapsed rows
body: <p>I have a dataset that is set up like the following mtcars summary:</p>
  <pre><code>mtcarssumm &lt;- mtcars %&gt;%
    group_by(cyl, gear) %&gt;% 
    summarise(meanMPG = mean(mpg)) %&gt;% 
    mutate(gear=as.character(gear)) %&gt;% 
    bind_rows(group_by(mtcars,cyl) %&gt;% 
    summarise(meanMPG=mean(mpg)) %&gt;% 
    mutate(gear='Total')) %&gt;% 
    arrange(cyl)
  
  cyl gear  meanMPG
     &lt;dbl&gt; &lt;chr&gt;   &lt;dbl&gt;
   1     4 3        21.5
   2     4 4        26.9
   3     4 5        28.2
   4     4 Total    26.7
   5     6 3        19.8
   6     6 4        19.8
   7     6 5        19.7
   8     6 Total    19.7
   9     8 3        15.0
  10     8 5        15.4
  11     8 Total    15.1
  
  </code></pre>
  <p>What I would like is to create a table using kableextra, where the rows with gear = Total to be shaded. I'm currently using row_spec to do this. I'm also using collapse_rows to collapse down the repeated values in cyl:</p>
  <pre><code>mtcarssumm %&gt;%
    kbl(booktabs = TRUE) %&gt;% 
    collapse_rows(1, latex_hline = &quot;major&quot;, valign = &quot;middle&quot;) %&gt;% 
    kable_styling() %&gt;% 
    row_spec(which(mtcarssumm$gear == &quot;Total&quot;), background = &quot;#e5e5e5&quot;)
  </code></pre>
  <p>When I convert to PDF, the entire row is shaded, as in the image below.</p>
  <p><a href="https://i.stack.imgur.com/IXZSR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IXZSR.png" alt="enter image description here" /></a></p>
  <p>Is there a way to use collapse_rows and row_spec so the shading is only in the rows that are not collapsed? (Note, this code gives the desired result in HTML output but not in PDF output.</p>
  <p>Thank you!</p>