maxcrees / tbl.typ

A tbl-like preprocessor for Typst and tablex
https://maxre.es/tbl.typ/
Mozilla Public License 2.0
8 stars 0 forks source link

Layout fails to converge when column width dominated by citation #11

Open tcztzy opened 10 months ago

tcztzy commented 10 months ago
layout did not converge within 5 attempts

Hint: check if any states or queries are updating themselves

I test all the styles, only "chicago-author-title" and "chicago-author-date" will occur this warning

maxcrees commented 10 months ago

Thanks for reporting. Can you provide an example document? Does the document render as expected?

I think this is a known issue with the underlying tablex library (see PgBiel/typst-tablex#38), but I can attempt to verify that with an example.

tcztzy commented 10 months ago

Thanks for reporting. Can you provide an example document? Does the document render as expected?

I think this is a known issue with the underlying tablex library (see PgBiel/typst-tablex#38), but I can attempt to verify that with an example.

Thx for you reply, here is the minimal case reproduce. https://gist.github.com/tcztzy/a158907df215fa1409f48817110a71d0

maxcrees commented 10 months ago

Thanks! I'll plan to investigate this tomorrow or Saturday.

maxcrees commented 10 months ago

This appears to be a tbl-specific issue caused by the use of citations within the table data - in particular when the citation text is the dominating factor in determining the column width. If there is some other constraint that makes the width of the column larger than the citation text, then no warning is generated.

The apparent dependence on the citation style is actually due to the fact that each citation style generates text that is wider or narrower than the "Reference" column header you've provided. If the generated citation text is wider than "Reference", then the citations are dominating the column width calculation - and the bug is triggered.

For now, a possible workaround is to add a minimum width column modifier that is slightly bigger than the widest citation, e.g. w(1.6i) in the example below:

```tbl
C C C Cw(1.6i)
R N.
Method | Year | Description | Reference
\_     | \_   | \_          | \_
RF     | 1981 | Robinson-Foulds distance | @robinson1981
KF     | 1994 | Kuhner-Felsenstein distance | @kuhner1994
PS     | 1985 | Path similarity |
SPR    | 1996 | Subtree prune and regraft distance | @hein1996
VTD    | 2022 | Vectorial tree distance | @priel2022

For my future reference, here is a smaller reproducer:

import "@preview/tbl:0.0.4"

show: tbl.template

L.
@foo

bibliography("bar.bib")



This will likely require extended time to resolve fully as it will necessitate debugging Typst itself to determine why the width measurements aren't converging.
maxcrees commented 10 months ago

I should also note that while the warning is troublesome and should be eliminated, it seems to me that the PDF output is otherwise correct. Whatever variances in the widths that are preventing the layout from converging must be exceedingly small.

I'll try to set aside some time next weekend to instrument the Typst compiler and figure out those variances exactly.

maxcrees commented 9 months ago

Issue is still present in Typst 0.8.0.

maxcrees commented 3 months ago

This issue will be fixed in the next release, which will switch from tablex to native Typst tables.