2

This is a follow-up question from this question, where I asked how to suppress bootstrap-layouting of tables in quarto v1.3. The solution was to add #| output: asis to the chunk-options and then add |> print_html() to the end of the code. This works perfectly for normal use. However, when used in a callout-block, printing the table as HTML seems to disable the callout-block. I found a workaround for this, which is to leave out the |> print_html(), like so:

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

::: {.callout-important}

Some text about the table

```{r}
#| echo: false
#| warning: false
#| output: asis

library(huxtable)

t1 <-  matrix(c("",            "",   "Success", "",     "", 
                "",            "",   "no",      "yes",  "", 
                "Medication",  "A",  4,         2,      6,
                "",            "B",  2,         5,      7,
                "",            "",   6,         7,      13),
              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)) |> 
  
  set_bold(row = 1, col = 3) |> 
  set_bold(row = 3, col = 1) |> 
  
  set_col_width(col = everywhere, 0.2)
```
:::

Again, this works fine, but it generates a grey line above the table, which I'd rather not have: I found, that this is caused by the last code-line set_col_width(), but I absolutely need to set the col-width because the table looks ridiculous without.

Any ideas on how I could get rid of that grey horizontal line?

DStuder
  • 45
  • 5

1 Answers1

2

While I don't know the cause of this grey line, you can remove it with some CSS:

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

```{css}
#| echo: false
.huxtable {
    border-top: hidden;
}
```

::: {.callout-important}

Some text about the table

```{r}
#| echo: false
#| warning: false
#| output: asis

library(huxtable)

t1 <-  matrix(c("",            "",   "Success", "",     "", 
                "",            "",   "no",      "yes",  "", 
                "Medication",  "A",  4,         2,      6,
                "",            "B",  2,         5,      7,
                "",            "",   6,         7,      13),
              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)) |> 
  
  set_bold(row = 1, col = 3) |> 
  set_bold(row = 3, col = 1) |> 
  
  set_col_width(col = everywhere, 0.2)
```
:::

enter image description here

bretauv
  • 7,756
  • 2
  • 20
  • 57
  • Perfect, that worked! I added the css-code to my `styles.css`-file so I don't have to repeat it for all 30 files. Thanks a lot! – DStuder Apr 07 '23 at 14:48