typst / typst/typst

Rotated content in the table cell align with `center + bottom` not aligned correct

Open
#4,788 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug layout
Dominant language
Rust
Stars
56.1k
Forks
1.7k
Avg merge
3d 10h
Merged PRs (30d)
22

Description

Description

I hope that after rotating the content in a table cell by -90 degrees, it will be centered and aligned downwards. However, I have found that using the rotate function does not center and align the selected content downwards as intended, but instead aligns it to the left. In contrast, using the rotatex function (from https://github.com/typst/typst/issues/528#issuecomment-1494318510) to rotate does not present this issue.

#let rotatex(body,angle) = style(styles => {
  let size = measure(body,styles)
  box(inset:(x: -size.width/2+(size.width*calc.abs(calc.cos(angle))+size.height*calc.abs(calc.sin(angle)))/2,
             y: -size.height/2+(size.height*calc.abs(calc.cos(angle))+size.width*calc.abs(calc.sin(angle)))/2),
             rotate(body,angle))
})

#table(
  columns: (1fr,) * 32,
  align: center + horizon,
  table.cell(colspan: 31)[],
  table.cell(align: center + bottom, rotatex([ABC], -90deg))
)

#table(
  columns: (1fr,) * 32,
  align: center + horizon,
  table.cell(colspan: 31)[],
  table.cell(align: center + bottom, rotate(-90deg, reflow: true, [ABC]))
)

image

Reproduction URL

No response

Operating system

Windows

Typst version
  • I am using the latest version of Typst

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided table reproduction and compare rotate(-90deg, reflow: true, [ABC]) with the custom rotatex helper. Trace how rotated content is sized and aligned inside table.cell(align: center + bottom, ...); done means the built-in rotation centers the content and aligns it downward like the helper.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.