Add header pitch and leading to clin_row_height() (#117) - #118
Merged
Conversation
The last of the three vertical controls #97 asked for. clin_row_height() owned the body, titles and footnotes but nothing reached the column header, so tightening a wrapped arm label meant a raw flextable::line_spacing(part = "header") in the project's styling function. The header needs two levers, not one, and measuring them settled which matters. `header` bounds the header rows the way `body` bounds the body rows - Word gets trHeight/atLeast - but under "atleast" it is a floor, so a header cell holding three lines still grows past it and the multi-line case is untouched. `header_leading` is what closes the gap between those lines: it lands as w:line, so 0.75 draws them three quarters as far apart. Both are available, and the docs say plainly which one reaches a wrapped label. Leading is the one measurement in this function that is not a length. flextable and Word both express it as a multiple of single spacing, so there is no points form to convert to and `unit` does not apply to it. It is named and documented as a multiple for that reason. Applied as the table renders rather than when the verb is called, because a styling function that calls line_spacing(part = "all") - as the CDISC pilot's does - would otherwise undo it. There is a test standing that styler up and checking the leading survives. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Jul 27, 2026
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #117. The last of the three vertical controls #97 asked for.
Measuring settled the design question you left open
You asked whether a
headerheight would reach the multi-line case, and suspected not. It doesn't. Reading what Word actually receives for a 3-line header cell:clin_row_height(body = 15.35)line=240,trHeight=796/autorule = "atleast"trHeight=260/atLeastrule = "exact"trHeight=260/exactline_spacing(space = 0.75)w:line=180So both ship, and the docs say which one to reach for.
headerbounds the header rows the waybodybounds the body rows;header_leadingcloses the gap between the lines inside a cell, which is what a wrapped arm label needs.Verified together:
hdr line=180,hdr trH=260/atLeast,body trH=307/atLeast— three independent pitches, none interfering.Leading is a multiple, not a length
The one wrinkle. flextable's
line_spacing()takes a multiple of single spacing and Word writes it that way —space = 0.75becomesw:line=180against a single-spacing 240, with nolineRule. There is no points form to convert to without hand-writingw:lineRule="exact", which would mean going around flextable into officer's XML.So
header_leadingis a multiple,unitdoes not apply to it, and it is named and documented accordingly rather than pretending to be a length like its neighbours.It has to be deferred, and your styler is why
Applied at verb-call time it would be undone: your
clinify_defaults.Rcallsflextable::line_spacing(x, space = 1, part = "all")in all three styling functions. So it is applied infinish_table_(), after the option styling function — the same precedence rule as the rest of the per-table config.There is a test that stands that styler up and checks the leading survives at 0.75 rather than being reset to 1.
Verification
devtools::check()— 0 errors, 0 warnings, and theunable to verify current timeNOTE, which is the no-network note this repo'scran-comments.mddocuments as local-only; it comes and goes between runs on this machine.R/row_height.R: 4, unchanged fromdevelopment.w:line,w:trHeightandhRuleout ofword/document.xml, so they check what Word receives rather than in-memory fields.Note
Thank you for the header line-structure check — the finding that 9 of 30 tables stack their header lines differently from the reference is exactly the kind of thing that justifies this being an API lever rather than a per-project workaround. Worth saying that
header_leadingchanges the leading, not where the lines break: if 14-1.02 is puttingp-valueon header line 5 where the reference has line 6, that is a wrapping/level-count difference rather than a spacing one, and this won't move it. Happy to look at that separately if you file it.DESCRIPTIONleft at 0.4.0 with the entry under# clinify (development version), as with #114/#115/#116.🤖 Generated with Claude Code