grimbough / msmbstyle

Tufte inspired bookdown template
https://www-huber.embl.de/users/msmith/msmbstyle/
59 stars 17 forks source link

Formatting of tables #21

Open aridus opened 5 years ago

aridus commented 5 years ago

Following this suggestion #https://github.com/grimbough/msmbstyle/issues/15 I can use this code

library(knitr)
library(kableExtra)
options(kableExtra.html.bsTable = T)
options(knitr.kable.NA = '')
data_sources <- read_csv("tables/data_sources.csv")
kable(data_sources) %>%
  kable_styling() %>% 
  row_spec(0, bold = F) %>% 
  row_spec(1, background = "#eff9fe") %>% 
  row_spec(6, background = "#eff9fe") %>% 
  row_spec(10, background = "#eff9fe") %>% 
  row_spec(15, background = "#eff9fe")

to style a table (although row_spec(0, bold = F) does not prevent bolding of the header row).

But the table is placed across the whole page (i.e. tab.margin = FALSE has no effect) and a citation of the usual form (Table \@ref(tab:data-sources)) does not link to the table.

Is there a solution to this problem?

Thanks!