Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to override bootstrap-styling for tables in Quarto v1.3?

I’m using Quarto to create a website which contains a lot of tables. Because I want the tables to have a specific look, I use huxtable to add borders. Take the following as an example:

```{r}
t1 = matrix(c("",         "menu",   "",      "",     "", 
              "",         "",       "yes",   "no",   "", 
              "group",    1,        1,        4,      5,
              "",         2,        5,        1,      6,
              "",         "",       6,        5,      11),
            nrow = 5, byrow = T)

huxtable::as_hux(t1) |> 
  set_bottom_border(row = c(2,4), col = 2:5) |>
  set_bottom_border(row = c(1,5), col = c(3,4)) |>
  set_right_border(row = 2:5, col = c(2,4)) |> 
  set_right_border(row = c(3,4), col = c(1,5)) |> 
  
  merge_cells(row = 1, col = 2:5) |> 
  merge_cells(row = c(3,4), col = 1) |> 
  set_align(row = everywhere, col = everywhere, "center")
```

This used to create beautiful tables. But since I upgraded to Quarto version 1.3, when rendering it seems to override my layout-inputs with a bootstrap-design. Now it looks ridiculous:
See here

Is there any way that I can suppress the bootstrap-layouting?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I tried setting the background to white using set_background_color(), but to no avail. I could use print_html(), copy the output and paste it after the code-block, but this gets messy real quick, as I have to make changes to these tables a lot.
Another solution I saw was specifying the table-layout in a .css-file, but this is also not great as I have a lot of tables in different sizes, so specifying the layout for all of the individually would be very tedious.

Any help would be appreciated.

>Solution :

Try print_html along with chunk option output: asis.

---
title: Table style
format: html
---

```{r}
#| output: asis

library(huxtable)

t1 = matrix(c("",         "menu",   "",      "",     "", 
              "",         "",       "yes",   "no",   "", 
              "group",    1,        1,        4,      5,
              "",         2,        5,        1,      6,
              "",         "",       6,        5,      11),
            nrow = 5, byrow = T)

huxtable::as_hux(t1) |> 
  set_bottom_border(row = c(2,4), col = 2:5) |>
  set_bottom_border(row = c(1,5), col = c(3,4)) |>
  set_right_border(row = 2:5, col = c(2,4)) |> 
  set_right_border(row = c(3,4), col = c(1,5)) |> 
  merge_cells(row = 1, col = 2:5) |> 
  merge_cells(row = c(3,4), col = 1) |> 
  set_align(row = everywhere, col = everywhere, "center") |> print_html()
```

huxtable printed

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading