Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit use of x (y) in cellx(x: ...) causes table rows to be uneven when rows parameter is set #97

Closed
Andrew15-5 opened this issue Dec 17, 2023 · 2 comments
Assignees
Labels
bug Something isn't working table-parity
Milestone

Comments

@Andrew15-5
Copy link

Here is the working example:

source

#import "@preview/tablex:0.0.6": tablex, rowspanx, colspanx, cellx

#set page(width: auto, height: auto)
#set text(size: 10pt)

#tablex(
  align: center + horizon,
  rows: 5mm,
  columns: (7mm, 10mm, 23mm, 15mm, 10mm, 70mm, 5mm, 5mm, 5mm, 5mm, 12mm, 18mm),
  ..range(5), cellx(rowspan: 3, colspan: 7)[],
  ..range(5),
  ..range(5),

  ..range(5), rowspanx(5)[], colspanx(3)[], colspanx(2)[], [],
  ..range(5), rowspanx(3)[], rowspanx(3)[], rowspanx(3)[], cellx(rowspan: 3, colspan: 2)[], rowspanx(3)[],
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3), colspanx(4)[], colspanx(2)[],

  colspanx(2)[], ..range(3), rowspanx(3)[], cellx(rowspan: 3, colspan: 6)[],
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3),
)

part of output

image

But adding x: 5, causes not only text on 1st, 5th, 9th, 11th rows to shift a bit, but also extends the last row's height:

source

#import "@preview/tablex:0.0.6": tablex, rowspanx, colspanx, cellx

#set page(width: auto, height: auto)
#set text(size: 10pt)

#tablex(
  align: center + horizon,
  rows: 5mm,
  columns: (7mm, 10mm, 23mm, 15mm, 10mm, 70mm, 5mm, 5mm, 5mm, 5mm, 12mm, 18mm),
  ..range(5), cellx(x: 5, rowspan: 3, colspan: 7)[],
  ..range(5),
  ..range(5),

  ..range(5), rowspanx(5)[], colspanx(3)[], colspanx(2)[], [],
  ..range(5), rowspanx(3)[], rowspanx(3)[], rowspanx(3)[], cellx(rowspan: 3, colspan: 2)[], rowspanx(3)[],
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3), colspanx(4)[], colspanx(2)[],

  colspanx(2)[], ..range(3), rowspanx(3)[], cellx(rowspan: 3, colspan: 6)[],
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3),
)

part of output

image

If I remove the unnecessary ..range(5), then most rows' text will move and the second to last row now also will extend its height.

source

#import "@preview/tablex:0.0.6": tablex, rowspanx, colspanx, cellx

#set page(width: auto, height: auto)
#set text(size: 10pt)

#tablex(
  align: center + horizon,
  rows: 5mm,
  columns: (7mm, 10mm, 23mm, 15mm, 10mm, 70mm, 5mm, 5mm, 5mm, 5mm, 12mm, 18mm),
  cellx(x: 5, rowspan: 3, colspan: 7)[],
  ..range(5),
  ..range(5),

  ..range(5), rowspanx(5)[], colspanx(3)[], colspanx(2)[], [],
  ..range(5), rowspanx(3)[], rowspanx(3)[], rowspanx(3)[], cellx(rowspan: 3, colspan: 2)[], rowspanx(3)[],
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3), colspanx(4)[], colspanx(2)[],

  colspanx(2)[], ..range(3), rowspanx(3)[], cellx(rowspan: 3, colspan: 6)[],
  colspanx(2)[], ..range(3),
  colspanx(2)[], ..range(3),
)

part of output

image

P.S. I'm using MuPDF in the screenshots.

@PgBiel PgBiel added the bug Something isn't working label Dec 17, 2023
@PgBiel
Copy link
Owner

PgBiel commented Dec 31, 2023

MRE:

#import "@preview/tablex:0.0.7": tablex, cellx

#tablex(
  rows: 5pt,
  cellx(x: 0, y: 1)[a\ a\ a\ a]
)

Produces (Typst 0.10.0):

The last row is larger than it should be

The last row is internally auto-sized.

@PgBiel PgBiel self-assigned this Dec 31, 2023
@PgBiel PgBiel added this to the v0.0.8 milestone Dec 31, 2023
@PgBiel
Copy link
Owner

PgBiel commented Dec 31, 2023

This was fixed for the next release, thanks for reporting! In the meantime, you can use tablex.typ from the 0.0.x branch - just download the file, place it in your project and import it.

@PgBiel PgBiel closed this as completed Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working table-parity
Projects
None yet
Development

No branches or pull requests

2 participants