haozhu233 / kableExtra

Construct Complex Table with knitr::kable() + pipe.
https://haozhu233.github.io/kableExtra/
Other
689 stars 147 forks source link

add_header_above() allow for supplying `line` argument as vector #700

Open tbbarr opened 2 years ago

tbbarr commented 2 years ago

Currently when adding headers to a kable object via add_header_above() if wanting to italicise/align certain headers differently this seems to be possible via a vector of arguments, e.g.:

some_kable %>%
    add_header_above(c("a header" = 1, "other header" = 2), italic=c(TRUE,FALSE), align=c("l", "c"))

However, doing the same with the line argument returns:

Warning message:
In if (line) { :
  the condition has length > 1 and only the first element will be used

It would be really nice to be able to also only draw a line under certain headers and not either all or no headers.

krivit commented 7 months ago

Seconding this: at the moment, the code uses a heuristic that if the column in the header above is blank, then there is no line under it, and if it has any non-whitespace, then there is.

Sometimes, finer control is required. For example, as far as I can tell, there is currently no way to typeset the following header:

|----------|---------------------|
| Multirow | Column group        |
|          | ------------------- |
| name     | Col 1      Col 2    |
|----------|---------------------|
|          |                     |
|          |                     |