Skip to content

Allow indexing the last n rows/column of tables in set / show rules of tables #5424

@pachi

Description

@pachi

Description

Would it be possible to have a way to refer to the last n column / row in a table when checking for its x or y value in formatting functions (in set or show rules)?

May be negative numbers (x=-1 or y=-1) or an special function like nlast_x(0) or nlast_y(0) would mean the last column / row?

Use Case

When defining tables it is very convenient being able to use functions that take x and y indices to format some rows of columns.

Thus, it's easy to define generic show rules for headers or leading columns, like this:

#show table.cell.where(x: 0): set text(style: "italic")
#set table(
  stroke: (_, y) => if y == 0 {
    (top: 1pt) 
  } else if y == -1 {
    (bottom: 1pt)
  } else if y == 1 {
    (top: 0.5pt )
  }
)

But the last example doesn't work as y=-1 is not a valid test but it would be very handy as it would allow setting an special format for the last row (or x=-1 for the last column). This avoids having to define custom elements or having to hardcode formats in each table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or requeststylingAbout set and show rules or style properties

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions