Search code examples
latexknitrkableextra

Subnumbering tables with kableExtra


I'm using Sweave (knitr) with kableExtra to generate tables like this:

enter image description here

Instead of Table 12, Table 13, I want to have Table 12(a), Table 12(b). How to do that?

One table is generated by such a code:

kable(dtabl, booktabs = TRUE, longtable = TRUE,
      align = rep("c", ncol(dtabl)), linesep = "",
      caption = paste0("Experimental Design of Qualification Data for level ", 
                       name, " of Group ", group),
      escape = FALSE) %>%
  add_header_above(extraheader) %>%
  kable_styling(latex_options = c("repeat_header", "striped"))

I have a capricious internet connection, I will firstly post this message and then edit to add some details.


Solution

  • Here is a LaTeX solution. Easy to adapt to Sweave (for example if you have an arbitrary number of tables).

    \renewcommand{\thetable}{\arabic{table}(a)}
    
    <<...>>=
    ...
    @
    
    \renewcommand{\thetable}{\arabic{table}(b)}
    
    \addtocounter{table}{-1}
    
    <<...>>=
    ...
    @