rstudio / gt

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

[feature request] Add option to remove header/footer border #361

Closed zenggyu closed 4 years ago

zenggyu commented 5 years ago

Please briefly describe your problem or your ideas for enhancement in the template below.

Have a question? Please don't use this form but instead ask on RStudio community, on Stack Overflow, or on Twitter (using the #rstats hashtag).

When describing a bug, please include a minimal reproducible example (otherwise known as a reprex).

When posting, delete these explanatory lines and submit only the text derived from the template below.


Some academic journals require that borders of table header and table footer (see below for an example taken from the intro page) be removed before submission, but currently I don't see any option to do this in gt.

屏幕截图_1

I think it'd be nice to have such feature.

zenggyu commented 5 years ago

I just found that cells_borders() may be the way to do it , but unfortunately it does not work as expected:

library(gt)
mtcars %>%
  head() %>%
  gt() %>%
  tab_header("Table 1. mtcars dataset") %>%
  tab_style(style = cell_borders(sides = "top", weight = px(0)),
            locations = cells_title("title"))

屏幕截图

rich-iannone commented 5 years ago

Thanks, this is a really good suggestion! In gt, I think we eventually want to get to a point where every single line and cell can be accessed and modified (and we actually need this for theming).

rich-iannone commented 4 years ago

Hi @zenggyu , this issue should be resolved now. Now you can take any gt table object and use these options (from tab_options()):

gt_table %>%
  tab_options(
    table.border.top.style = "hidden",
    table.border.bottom.style = "hidden"
  )
balthasars commented 8 months ago

There is an even more specific solution to remove the border below your footnotes:

gt_table |>
  tab_options(
    footnotes.border.bottom.style = "hidden"
  )

Mentioning this because table.border.bottom.style = "hidden" will also remove formatting of table borders you may have previously applied.