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

Spanning table columns can extend beyond the edge of the page #1368

Closed
myii opened this issue Nov 5, 2019 · 5 comments
Closed

Spanning table columns can extend beyond the edge of the page #1368

myii opened this issue Nov 5, 2019 · 5 comments
Assignees
Milestone

Comments

@myii
Copy link

myii commented Nov 5, 2019

Related issue

May be a duplicate of #900.

Asciidoctor file

= Bug: Spanning table columns

.Without spanning
[format="psv", cols="25d,25d,25d,25d"]
|===
|a |b |c |d
|===

.Using equal column sizes appears to work
[format="psv", cols="25d,25d,25d,25d"]
|===
// |a |b |c |d
|e 3+|f
2+|g |h |i
|===


.Adjusting column sizes slightly results in a larger table width
[format="psv", cols="24d,24d,24d,28d"]
|===
// |a |b |c |d
|e 3+|f
2+|g |h |i
|===

.Adjusting column sizes further results in the table extending to the edge of the page
[format="psv", cols="20d,20d,20d,40d"]
|===
// |a |b |c |d
|e 3+|f
2+|g |h |i
|===
  • Note, if the commented row in each table is uncommented, this bug isn't triggered.
    • It doesn't have to be the first row; it works for any of the rows.

Theme

Using the default theme.

Command

$ asciidoctor-pdf bug_spanning-table-columns.adoc

Result

screenshot102

@mojavelinux
Copy link
Member

The problem here is when there isn't at least one row that has cells without colspans. That seems to throw off the calculation for the individual column widths.

@mojavelinux
Copy link
Member

Keep in mind that the column widths are ratios. So they don't have to add up to 100. Though, clearly the computed widths do need to add up to the available space.

@mojavelinux
Copy link
Member

Here's the most minimal case:

[cols=20;20;20;40]
|===
|e 3+|f
2+|g |h |i
|===

@mojavelinux
Copy link
Member

It turns out, prawn-table is computing the width of the columns even when we pass it the precomputed column widths. (I have no idea why). And since there's clearly a bug in the column width calculation in certain scenarios when colspan is used, the table ends up with incorrect column widths that overrun the width of the page.

I'll update the converter to force prawn-table to use the column widths that we give it. While that doesn't fix the computation in prawn-table, it does sidestep it. What that means is that this could still happen if you set the autowidth option on the table. But the obvious workaround when this happens is to take away the autowidth option (since we can't rely on the prawn-table's calculations).

@mojavelinux mojavelinux self-assigned this May 22, 2022
@mojavelinux mojavelinux added this to the v2.0.x milestone May 22, 2022
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 22, 2022
…n column width calculation when using colspans
mojavelinux added a commit to mojavelinux/asciidoctor-pdf that referenced this issue May 22, 2022
…n column width calculation when using colspans
@mojavelinux
Copy link
Member

It turns out that prawn-table does make this mistake when the autowidth option is specified. So this still works:

[.stretch%autowidth]
|===
|a 3+|b
2+|c |d >|e
|===

For all the cases I can come up with so far, this patch fixes the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants