Skip to content

Primes should not further raise next superscript's position - #4492

Merged
laurmaedje merged 4 commits into
typst:mainfrom
Leedehai:primes-3043
Jul 8, 2024
Merged

laurmaedje merged 4 commits into
typst:mainfrom
Leedehai:primes-3043

Conversation

@Leedehai

@Leedehai Leedehai commented Jul 3, 2024 •

Copy link
Copy Markdown
Contributor

Updated approach: this is done by merging the primes with the top-right attachment, if any. This way, the top-right attachment following the prime symbol won't be pushed further upward.

Fixes #3043. All other tests are passing.

Initial approach

Building upon #3059, this patch expands the usage of the text_like property of FrameFragments. This is justified by the fact that when handwriting expressions, people treat e.g. f' as one single textual symbol just like f, instead of treating it as an compound expression like (a+b). So in an AttachElem, the result frame's text_like property should inherit from the base's.


The observation above is reflected in LaTeX's rendering of the prime symbol: it should keep the vertical position of following superscripts as if the prime symbol doesn't exist. This makes the equation look more pleasant especially there are square roots or fractions. Contrast:

$
  sqrt(f^2)/f^2
  sqrt(f'^2)/f'^2
  sqrt(f'_n^2)/f'_n^2
  sqrt(f'''''^2)/f'''''^2
$

Typst (before the change, commit aefc506):

Typst (after the change):

LaTeX:

$
  \frac{\sqrt{f^2}}{f^2}
  \frac{\sqrt{f'^2}}{f'^2}
  \frac{\sqrt{f'_n^2}}{f'_n^2}
  \frac{\sqrt{f'''''^2}}{f'''''^2}
$

Comment thread crates/typst/src/math/attach.rs Resolved
Comment thread crates/typst/src/math/attach.rs Resolved
Comment thread crates/typst/src/math/attach.rs Resolved
@laurmaedje
laurmaedje added this pull request to the merge queue Jul 8, 2024
@laurmaedje

Copy link
Copy Markdown
Member

Thank you, this is nice!

Merged via the queue into typst:main with commit d1c7d08 Jul 8, 2024
@Leedehai
Leedehai deleted the primes-3043 branch July 8, 2024 22:05
Myriad-Dreamin pushed a commit to Myriad-Dreamin/typst that referenced this pull request Jul 9, 2024
Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
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.

Primes on symbols lead to misaligned superscripts: they are pushed upward

3 participants