rstudio / gt

Easily generate information-rich, publication-quality tables from R
https://gt.rstudio.com
Other
1.99k stars 201 forks source link

Any way to remove the underline underneath column spanners? #838

Open akfaour opened 2 years ago

akfaour commented 2 years ago

Great package.

Column spanners automatically have an underline underneath, any way to remove or modify the line? I am having a problem where there is a gap between the spanner underline and the vertical lines in the column headers - see below.

Screen Shot 2021-09-19 at 10 36 39

Setting a bottom border for the spanner using:

tab_style(style = list(cell_fill(color = "#BEBEBE"), cell_text(align = "center"), cell_borders(sides = "bottom", style = "solid", weight = px(1))), locations = list(cells_column_spanners(spanners = everything())))

results in this:

Screen Shot 2021-09-19 at 10 40 39

I would like to get rid of the gap between the spanner underline, so there is a smooth horizontal line throughout the column labels?

Thank you.

epbmd commented 2 years ago

Would love to know how to accomplish this as well!

kit-hcrn commented 2 years ago

Try the following. You need to assign an id to the gt table object. You can then use that to reference individual attributes and modify their css.

`library(gt)

gtcars %>% gt(id = "table") %>% tab_spanner( label = "Car Type", columns = c(mfr, model) ) %>% opt_css( css = "

table .gt_column_spanner {

    border-bottom-width: 0px;
    }"

)`

akfaour commented 2 years ago

@hoosiercancer thank you that worked!

rich-iannone commented 2 years ago

Glad to see there's a workaround for this! However, there should be cell_borders() solution as well.