insightsengineering / insightsengineering/crane

[Feature Request]: fixed layout for flextable

Open
#150 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
R
Stars
15
Forks
7
Avg merge
6d 9h
Merged PRs (30d)
5

Description

### Feature description

Currently, exporting gtsummary objects relies on flextable. User frequently want to set manually the width of the column, however, upon export of the flextable to docx, this manually selected column width is not respected. To solve this issue, users have to manually specify that the layout of the flextable is "fixed" (`flextable::set_table_properties(layout = "fixed")`). Could we intergrate that bit to the roche theme so that flexable object comming from gtsummary object have a fixed layout by default

e.g.

```r
fixed_theme <- list(
# This runs code on the flextable object immediately after conversion
"pkgwide-fun:pre_conversion" = function(x) {
if (inherits(x, "flextable")) {
x %>%
set_table_properties(layout = "fixed") %>%
width(j = 1, width = 2.5, unit = "in") # Always make first column 2.5 inches
} else {
x
}
}
)

set_gtsummary_theme(fixed_theme )
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [x] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [x] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.