The reason why the row height is not always equal is that by default,?kable?inserts a?addlinespace
every 5 rows when booktabs is specified as TRUE, as is shown here:
linesep = if (booktabs) c('', '', '', '', '\addlinespace') else '\hline'
To alter this, add?linesep = ""
as an argument to kable()
.
knitr::kable(
head(iris, 20), caption = 'Here is a nice table!',
booktabs = TRUE,
linesep = ""
)
See?Get rid of addlinespace in kable?for more details.
It is also worth saying that you can play around with this option if you want to change the style. For example linesep = c("", "", "", "\hline")
would add a horizontal line every four spaces.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…