Skip to content

pack_rows break footnote alignment #880

@zjllee

Description

@zjllee

Describe the bug
If I use pack_rows(), the left aligned footnote becomes centre-aligned on the 1st column instead. When pack_rows() is not used the footnote becomes left-aligned again.

#| tbl-cap: "Summary statistics."
#| echo: false
#| message: false
#| warning: false

library(knitr)
library(kableExtra)
library(glue)

sample_size <- nrow(df) # get sample size dynamically

summary_df %>%
    kbl(
        col.names = c("", "Mean", "Std Dev"),
        row.names = FALSE,
        align = "lrr",
        escape = FALSE
    ) %>%
    kable_paper(font_size = 6) %>%
    column_spec(1, width = "80%") %>%
    column_spec(2, width = "10%") %>%
    column_spec(3, width = "10%") %>%
    pack_rows(index = c("Key variables" = 4, "Control variables" = 18)) %>%
    # pack_rows("Key variables", 1, 4) %>%
    # pack_rows("Control variables", 5, 22) %>%
    footnote(general = glue("The summary statistics are calculated from the estimation sample of morning commutes. The sample size is {sample_size}.")
    )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions