Skip to content

Baseline control in grids and tables #5225

Open

Description

@woerndl

Description

To the best of my knowledge, there is no simple and reliable way to control the line height and baseline alignment of text placed next to each other. I assume this issue is related to #493, #4224, and #4755. By "reliable," I mean that the baseline parameter of both #text and #box is inadequate because it breaks when the font or font size changes. I wanted to highlight this basic and common case as an issue because it demonstrates that this is a fundamental problem, not just related to emojis or "edge cases."

Consider this MWE

#place(dy:0.68em, stack(spacing: 2.96em,
  ..(line(
    length: 100%,
    stroke: .25pt + gray,
  ),)*3
))
#grid(
  columns: (0.2fr, 1fr),
  row-gutter: 1em,
  text(8pt)[Flying Title],
  [The list item text.\ Can span around multiple lines.],
  text(8pt, baseline: 0.25em)[Baseline Title],
  [The list item text.\ Can span around multiple lines.],
  par(leading: 11pt, {text(8pt)[Paragraph Test]}),
  [The list item text.]
)

Which leads to
example

Use Case

There is probably no silver bullet, but having a "real" line-height option could be a great start. For tables and grids, a vertical alignment to the baseline would be an even better solution, potentially allowing not just alignment to the first baseline but optionally to the n-th baseline.

Activity

  1. added
    feature request
    on Oct 17, 2024
  2. added
    layout
    on Oct 17, 2024
  3. wisp3rwind commented on Nov 28, 2024

    @wisp3rwind

    As a workaround, I'm now putting content with #text("The cell content", top-edge: "ascender") (for the first line of the cell only, otherwise, line spacing is affected) in my tables. By forcing identical line height in all columns, this makes baselines align for top-aligned table cells. However, it's a huge manual mess and it might also effectively increase padding at the top if lines are not actually that high. It'd be great if proper baseline alignment could be prioritized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestlayout

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions