7
votes

I am using kable to make tables of my data in RMarkdown. You can supposedly adjust column width using the column_spec command, however this seems to adjust only the columns of the data, itself, but does not also adjust the column width of my header row. So now my headers no longer line up with their associated column of data.

For example:

    y <- knitr::kable(head(mtcars), "html")
    column_spec(y, 1:4, width="5em")
1
it's a bug introduced in kableExtra 0.6.0. I will fix it - Hao
I recently added css display: inline-block; for a more consistent column width behavior (see this ) but at the same time, it makes the column header unable to auto adjust to the column width in the table body. - Hao
@Hao - Thank you! I tried using width="5em; display: inline-block;" within the column_spec() command, but it doesn't seem to have changed anything - let me know if/when you have another solution! :) - Alison K.
oh, it's not a solution. I was saying the solution in the other post caused the problem - Hao
@Hao - ahh ok, I misunderstood - thanks for clarifying. - Alison K.

1 Answers

0
votes

Author of kableExtra, Hao Zhu, mentioned in the comments that this was a bug in kableExtra 0.6.0 and fixed version was released. Looking at the commit history, this commit removing the inline-block style should be the fix.

At the time of writing this kableExtra is on version 0.9.0 already, so this shouldn't happen with the current version.