Skip to content

Unify layout of vec and cases with mat#5934

Merged
laurmaedje merged 4 commits intotypst:mainfrom
mkorje:unify-vec-mat
Mar 31, 2025
Merged

Unify layout of vec and cases with mat#5934
laurmaedje merged 4 commits intotypst:mainfrom
mkorje:unify-vec-mat

Conversation

@mkorje
Copy link
Collaborator

@mkorje mkorje commented Feb 23, 2025

Closes #5422.

--- math-mat-vec-cases-unity ---
// Test that matrices, vectors, and cases are all laid out the same.
$ mat(z_(n_p); a^2)
  vec(z_(n_p), a^2) 
  cases(reverse: #true, delim: \(, z_(n_p), a^2)
  cases(delim: \(, z_(n_p), a^2) $
Old New
old_math-mat-vec-cases-unity new_math-mat-vec-cases-unity

The test math-equation-font also needed to be updated due to this change.

This PR also makes linebreaks be ignored in vec and cases now (cf. #5459), matching mat. A warning is now emitted when a linebreak is encountered in all three functions:

warning: linebreaks are ignored in cells
  ┌─ tests/suite/playground.typ:2:39
  │
2 │ $ cases(a, b, c) cases(reverse: #true, a \ b \ c) $
  │                                        ^^^^^^^^^
  │
  = hint: use commas instead to separate each line

The warning/hint can probably be improved. I'd appreciate any suggestions.
Only concern/note I have is that the hint in the above warning is kind of misleading with mat, as a semicolon ends a row. Though even if the hint also suggested using semicolons, it wouldn't be very helpful I think in a scenario like:

warning: linebreaks are ignored in cells
  ┌─ tests/suite/playground.typ:2:15
  │
2 │ $ mat(1, 2, 3; 4 \ 5, 6; 7, 8 \ 9) $
  │                ^^^^^
  │
  = hint: use commas instead to separate each line

warning: linebreaks are ignored in cells
  ┌─ tests/suite/playground.typ:2:28
  │
2 │ $ mat(1, 2, 3; 4 \ 5, 6; 7, 8 \ 9) $
  │                             ^^^^^
  │
  = hint: use commas instead to separate each line

@MDLC01
Copy link
Collaborator

MDLC01 commented Feb 23, 2025

Ideally, the warning should be different for all elements. For example, the "cell" terminology does not make much sense for cases.

@mkorje mkorje marked this pull request as draft February 26, 2025 10:47
@laurmaedje laurmaedje added the math Related to math category, with its syntax, layout, etc. label Mar 24, 2025
@mkorje
Copy link
Collaborator Author

mkorje commented Mar 25, 2025

Ideally, the warning should be different for all elements. For example, the "cell" terminology does not make much sense for cases.

I've modified it to be consistent with the terminology in the docs: cell, element, and branch for mat, vec, and cases respectively.

@mkorje mkorje marked this pull request as ready for review March 25, 2025 12:50
@laurmaedje laurmaedje added this pull request to the merge queue Mar 31, 2025
@laurmaedje
Copy link
Member

Thank you!

Merged via the queue into typst:main with commit 012e14d Mar 31, 2025
7 checks passed
@mkorje mkorje deleted the unify-vec-mat branch March 31, 2025 11:32
hongjr03 pushed a commit to hongjr03/typst that referenced this pull request Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

math Related to math category, with its syntax, layout, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Different appearance of vec and mat

3 participants