Closed dixslyf closed 9 months ago
Indeed, when this feature was added I intended to add negative expand, but it turned out to be more complicated than I thought. The problem is mostly that the line can span multiple cells, and currently lines are broken down to each cell they span, so we'd need to reduce the line across cell boundaries. This will probably be done at some point, but will take a while. Thanks for the request!
Marking this issue as a bug - single cell negative expansion is supposed to work (and apparently doesn't work, as described in #84); it's negative expansion across cells which isn't expected to work.
To summarize, some negative lengths do not work:
#import "@preview/tablex:0.0.6": tablex, hlinex
#tablex(
columns: (100%,),
auto-lines: false,
hlinex(),
[],
hlinex(expand: -10pt),
[],
hlinex(expand: -1em), // Does not work
[],
hlinex(expand: -5%),
[],
hlinex(expand: -5% - 10pt - 5em), // Does not work
)
Using fr
causes a panic, which is expected, but the error message isn't very clear:
#tablex(
columns: (100%,),
auto-lines: false,
hlinex(),
[],
hlinex(expand: -0.5fr),
)
[16:21:28] compiled with errors
error: panicked with: "'expand' argument to lines must be a pair (length, length)."
┌─ @preview/tablex:0.0.6/tablex.typ:2213:29
│
2213 │ panic("'expand' argument to lines must be a pair (length, length).")
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: error occurred in this call of function `map`
┌─ @preview/tablex:0.0.6/tablex.typ:2224:16
│
2224 │ hlines: hlines.map(parse-func.with(page-size: page-width)),
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: error occurred in this call of function `_parse-lines`
┌─ @preview/tablex:0.0.6/tablex.typ:2632:27
│
2632 │ let parsed_lines = _parse-lines(hlines, vlines, styles: styles, page-width: page_width, page-height: page_height)
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I'll create a separate issue for negative line expansion across cells since this issue is more about single-cell negative expansion, which will probably be resolved by #84.
It would be great if
expand
can be set to a negative value forhlinex
andvlinex
to shorten the line. As of now, settingexpand
to a negative value does not seem to do anything (v0.0.6
).