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

How can I remove the horizontal line that is added when printing huxtable in callout-block in Quarto v1.3?

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?

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

>Solution :

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

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