Line Breaks

Testing Line Breaks output

Line breaks not being rendered correctly in a PDF is a known issue. We will skip the quarto rendered PDF and evaluate the line break behavior in other output options.

The example table evaluates line breaks in: - Title - Column Headers - Table Header - Cells

library(gtsummary)
tbl <- gtsummary::tbl_summary(gtsummary::trial, by = trt, include = c(age, grade), missing = "always", label = list(age = "Age  \n\U00A0\U00A0linebreak in a cell")) |> add_overall()
gt_table <- tbl$table_body |> 
  gt::gt(caption = gt::md("This is the caption  \n[Used for cross referencing in Quarto]")) |> 
  gt::fmt_markdown(columns = label) |> # need this to recognize the line break in the table body
  # Column headers with line breaks
  gt::cols_label(
    stat_0 = gt::md("**Overall**"),
    stat_1 = gt::md("**Drug A**  \nManual Line Break"), 
    stat_2 = gt::md("**Drug B**  \nManual Line Break")
  ) |> 
  gt::tab_header(gt::md("This is the Title  \nwith a linebreak"), subtitle = "This is the Subtitle")

gt_save PDF

gt::gtsave(gt_table, filename = "outputs/pdf/linebreaks_gt_pdf.pdf")

Preview the Output

rmarkdown rendered PDF

gt_table

Preview the Output

gt_save rendered word file

gt::gtsave(gt_table, filename = "outputs/docx/linebreaks_gt_word.docx")

Preview the Output

quarto rendered word file

gt_table

Preview the Output

rmarkdown rendered word file

gt_table

Preview the Output