Just realised you are using gt rather than GT summary and there is no conversion function from gt.
df %>%
flextable() %>%
flextable::set_caption("Testing how to do a line break") %>%
set_header_labels(col1="Single", col2="Double\nEntry", col3="Another\nDouble Entry")
Would do what you want IF you aren't constrained to GT as a function
Kable seems to be a pain to do it in the headers. Hux may work - but I'm getting basic errors with hux.
seems to be related to your way of creating a new line.
I think I have seen a function to create new lines that would work in html and latex outputs, but I could not find it anymore (sorry...) anyone knows better ?
It's not optimal, but you could use gtsave() to save the image as a png, and insert it that way for pdf/latex. If you want multiple output formats, you can have separate table output by determining the output format - i.e gt table for html etc, and image of gt for pdf/latex, using is_latex_output(). example