Skip to content

Add pr_section for fine-grained Word section control in save_flex_docx()#2438

Merged
ddsjoberg merged 1 commit into
feat/as_flex_wordfrom
feat/save-flex-docx-pr-section
Jul 5, 2026
Merged

Add pr_section for fine-grained Word section control in save_flex_docx()#2438
ddsjoberg merged 1 commit into
feat/as_flex_wordfrom
feat/save-flex-docx-pr-section

Conversation

@ddsjoberg

Copy link
Copy Markdown
Owner

What changes are proposed in this pull request?

Add a pr_section argument (and matching save_flex_docx-lst:pr_section theme element) to save_flex_docx() accepting an officer::prop_section() object for fine-grained control of the Word section—page margins, page size, orientation, and columns—while the header/footer regions remain managed by save_flex_docx(); for a collection the same section is applied to every table with the paging type fixed to "nextPage".

If there is an issue associated with this pull request, please provide link.

N/A


Reviewer Checklist (if item does not apply, mark is as complete)

  • Ensured this PR is not the source of a merge conflict
  • PR branch is up to date with the base branch (merge or rebase before review)
  • Code coverage is suitable for any new functions/features (covr::report())
  • usethis::use_spell_check() run and no spelling errors in documentation
  • R CMD Check runs without errors, warnings, and notes (relevant test suite passes locally)
  • Code is well documented and follows tidyverse style guide

When the branch is ready to be merged:

  • Update NEWS.md with the changes from this pull request under the heading "# gtsummary (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (see NEWS.md for examples).
  • Increment the version number using usethis::use_version(which = "dev")
  • Run pkgdown::build_site() and merge any changes needed

Notes

This PR is stacked on feat/as_flex_word (PR #2437), not main — it builds on the flextable/list input support from that branch. Please merge #2437 first, after which this PR's base can be retargeted to main (or it will auto-retarget on merge).

Key behavior:

  • Header/footer always owned by the function — any header_default/footer_default on the supplied pr_section are discarded in favor of the relocated caption/notes.
  • Collections force type = "nextPage" — the same pr_section applies to every table's section; any type on pr_section is ignored between tables to avoid blank pages.
  • Always applied — a single table with no caption/notes still gets the section (so margins/size take effect).
  • Precedence — the pr_section argument overrides the save_flex_docx-lst:pr_section theme element.

All test-save_flex_docx.R tests pass (NOT_CRAN=true), including 8 new tests covering margins, ours-wins, no-content, collections, list input, theme element + override, and class validation. No NAMESPACE drift; man/ and R/sysdata.rda regenerated.

Add a pr_section argument (and matching save_flex_docx-lst:pr_section theme
element) accepting an officer::prop_section() to control page margins, page
size, orientation, and section columns. The header/footer regions remain
managed by save_flex_docx() (relocated caption/notes), so any
header_default/footer_default on pr_section are ignored. For collections the
same section is applied to every table with the paging type fixed to
'nextPage' to avoid blank pages. The argument overrides the theme element.

Co-authored-by: Ona <no-reply@ona.com>
@ddsjoberg ddsjoberg marked this pull request as ready for review July 5, 2026 20:49
@ddsjoberg ddsjoberg merged commit a98401e into feat/as_flex_word Jul 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant