Skip to content

Handle multi stub in word#2074

Merged
rich-iannone merged 14 commits intorstudio:masterfrom
thebioengineer:multi_stub_word
Nov 17, 2025
Merged

Handle multi stub in word#2074
rich-iannone merged 14 commits intorstudio:masterfrom
thebioengineer:multi_stub_word

Conversation

@romainfrancois
Copy link
Copy Markdown
Contributor

@romainfrancois romainfrancois commented Nov 11, 2025

Summary

This is bare minimum (wip) support for multi column stub for word.

This will need some more testing inspired by the test-multicolumn_stub.R file, as well as probably handling of the vertical cell merging in the stub. But that's a start ...

Marking as draft until we can address those.

Related GitHub Issues and PRs

  • Ref: #

Checklist

@romainfrancois romainfrancois marked this pull request as ready for review November 12, 2025 12:55
n_stubh_label <- length(stubh$label)
if (isTRUE(stub_available) && n_stubh_label > 0L) {
if (n_stubh_label != n_stub_cols) {
stub_labels <- c(stubh$label, rep("", n_stub_cols - 1L))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so sure about this stuff. This happens when there is only one stub label, but multi stub columns, so using the label for the first and then empty for the others.

Should the cells merge instead ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Word I think:

  • if there’s one stubhead label, place it in the rightmost stub column (don’t merge cells)
  • if supplied stubhead labels equals number of stubhead columns (place them right-to-left from the input order)
  • lengths of stubhead labels not 1 or n stubhead columns should error

tldr: merging cells is probably difficult in Word so don’t worry about doing that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it's not that big deal, the "span" cell here just needs a <w:gridSpan/> node in the cell properties:

Screenshot 2025-11-13 at 12 29 42
      <w:tcPr>
        <w:tcBorders>
          <w:top w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
          <w:bottom w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
          <w:end w:val="single" w:space="0" w:color="D3D3D3"/>
        </w:tcBorders>
        <w:gridSpan w:val="2"/>   <!-- HERE -->
      </w:tcPr>
      

I guess we can easily adjust that we had "one" instead of c("one", "two", "three") for stubh$label

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did eventually go in that direction, with tests to back it up. cc @shannonhaughton @thebioengineer

So for example the "one" stub label cell in this table (last test in test_that("multicolumn stub are supported")

Screenshot 2025-11-13 at 14 54 59

is made of these two tc with these tcPr:

      <w:tcPr>
        <w:tcBorders>
          <w:top w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
          <w:start w:val="single" w:space="0" w:color="D3D3D3"/>
          <w:end w:val="single" w:space="0" w:color="D3D3D3"/>
        </w:tcBorders>
        <w:vMerge w:val="restart"/>
        <w:vAlign w:val="bottom"/>
        <w:gridSpan w:val="3"/>
      </w:tcPr>

and

      <w:tcPr>
        <w:tcBorders>
          <w:bottom w:val="single" w:sz="16" w:space="0" w:color="D3D3D3"/>
          <w:start w:val="single" w:space="0" w:color="D3D3D3"/>
          <w:end w:val="single" w:space="0" w:color="D3D3D3"/>
        </w:tcBorders>
        <w:vMerge w:val="continue"/>
        <w:gridSpan w:val="3"/>
      </w:tcPr>

Copy link
Copy Markdown
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rich-iannone
Copy link
Copy Markdown
Member

This is great! I'll fix that small test failure in a separate commit and merge this.

@rich-iannone rich-iannone merged commit fbc48cd into rstudio:master Nov 17, 2025
10 of 11 checks passed
@romainfrancois romainfrancois deleted the multi_stub_word branch November 17, 2025 07:36
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.

2 participants