How do I make sure my huxtable list maintains formatting when writing to docx in R/Quarto?

I am using huxtable in Quarto in R for a pretty complicated table, and I need to make sure I have running headers when I knit to word. The headers will have their own formatting that needs to be maintained, as well as the formatting throughout the rest of the table.

In the example below I am using as some trial-and-error data, I am able to break the huxtable into multiple parts using split_across which then has a running header that consists of 3 rows. In R, it renders with the text color and bold. But when I Render the qmd file to Word, it removes the special formatting. Has anyone else had this problem? If so, is there a work around, or am I missing something in my code? Or is there a better alternative out there? Any suggestions much appreciated!

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>---
format: docx
editor: visual
---
{r test, echo=FALSE, message=FALSE, warning=FALSE}
require(huxtable)
myfaketable <- data.frame(yee = rep("test1", 50),
haw = rep("test2", 50))
myfaketable[1,] <- c("this is", "header 1")
myfaketable[2,] <- c("this is", "header 2")
myfaketable2 <- huxtable::as_hux(myfaketable) |>
huxtable::set_all_borders(brdr(1, "solid", "black"))
myfaketable2 <- huxtable::set_header_rows(myfaketable2, 1, TRUE)
myfaketable2 <- huxtable::set_header_rows(myfaketable2, 2, TRUE)
myfaketable2 <- huxtable::set_header_rows(myfaketable2, 3, TRUE)
myfaketable2 <- style_headers(myfaketable2,
bold = TRUE,
text_color = "purple"
)
myfaketable2_list <- (split_across(myfaketable2, after = c(15, 30, 45), headers = TRUE))
myfaketable2_list
</code>
<code>--- format: docx editor: visual --- {r test, echo=FALSE, message=FALSE, warning=FALSE} require(huxtable) myfaketable <- data.frame(yee = rep("test1", 50), haw = rep("test2", 50)) myfaketable[1,] <- c("this is", "header 1") myfaketable[2,] <- c("this is", "header 2") myfaketable2 <- huxtable::as_hux(myfaketable) |> huxtable::set_all_borders(brdr(1, "solid", "black")) myfaketable2 <- huxtable::set_header_rows(myfaketable2, 1, TRUE) myfaketable2 <- huxtable::set_header_rows(myfaketable2, 2, TRUE) myfaketable2 <- huxtable::set_header_rows(myfaketable2, 3, TRUE) myfaketable2 <- style_headers(myfaketable2, bold = TRUE, text_color = "purple" ) myfaketable2_list <- (split_across(myfaketable2, after = c(15, 30, 45), headers = TRUE)) myfaketable2_list </code>
---
format: docx
editor: visual
---

{r test,  echo=FALSE, message=FALSE, warning=FALSE}

require(huxtable)

myfaketable <- data.frame(yee = rep("test1", 50),
                          haw = rep("test2", 50))
myfaketable[1,] <- c("this is", "header 1")
myfaketable[2,] <- c("this is", "header 2")

myfaketable2 <- huxtable::as_hux(myfaketable) |>
    huxtable::set_all_borders(brdr(1, "solid", "black"))

myfaketable2 <- huxtable::set_header_rows(myfaketable2, 1, TRUE)
myfaketable2 <- huxtable::set_header_rows(myfaketable2, 2, TRUE)
myfaketable2 <- huxtable::set_header_rows(myfaketable2, 3, TRUE)

myfaketable2 <- style_headers(myfaketable2,
       bold       = TRUE,
       text_color = "purple"
     )

myfaketable2_list <- (split_across(myfaketable2, after = c(15, 30, 45), headers = TRUE))

myfaketable2_list

I have knit the document both with and without a custom reference doc (will be using a custom reference doc for the actual data), but neither keeps the formatting. I tried converting the list to a flextable to see if I could make something work there, but I can’t convert a list (and I’m not sure it would maintain my other formatting anyways).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật