I'm having trouble formatting an autowidth table when the header cell is wider than all the cells in the column: the header cell wraps unnecessarily (even if the header is only one word, the last letter wraps).
Here is an example of three tables: [options="header,autowidth"] |==== |Header Cell |text |==== [options="header,autowidth"] |==== |Header |text |==== [options="header,autowidth"] |==== |Header |more text |==== Formatting with asciidoctor-pdf looks like this... ![]() Conversion to HTML (with plain asciidoctor) works fine. Is my syntax incorrect, or is there a workaround I can use? |
Administrator
|
You are not doing anything wrong. However, you do need to upgrade prawn-table. This was an upstream bug and has since been fixed. However, prawn-table has yet to be released with this fix, so you have to load the gem from GitHub. See https://github.com/asciidoctor/asciidoctor-pdf/issues/599#issuecomment-485709277 for instructions and an explanation. Best, -Dan On Sat, Oct 12, 2019 at 3:07 PM jtkorb [via Asciidoctor :: Discussion] <[hidden email]> wrote: I'm having trouble formatting an autowidth table when the header cell is wider than all the cells in the column: the header cell wraps unnecessarily (even if the header is only one word, the last letter wraps). -- Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
This post was updated on .
Thanks--this solution worked for some of my tables, but (sorry for the trouble), here are two similar tables for which it didn't work:
[options="header,autowidth"] |======================================================================= |Operator |Description |X |Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. |=======================================================================The output exhibits the same problem: "Operator" is split across two lines, with the second "r" on a line by itself. The second example... If a single-word, non-header column cell is long, then it gets wrapped. For example, [options="header,autowidth"] |======================================================================= |Operator |Description |OperatorLong |Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. |=======================================================================Output of these two cases is shown below: ![]() EDIT 1: I was able to work around the problem by adding two-four {nbsp}s to the longer cell. EDIT 2: Actually, using {nbsp} doesn't always work, since the padded cell looks like it spans multiple lines, throwing off the vertical alignment in the row. Tim |
Administrator
|
Tim, This behavior is outside of the scope of Asciidoctor PDF. And it's working as designed in prawn-table. The right column requires more space, so it forces the left column to shrink. This, in turn, shrinks the width of the head cell, which then forces the word to break. The width of the body cell takes precedence over the width of the head cell. There are two things you could do. First, you can set a ratio for the columns and a width for the table to give the left column more room to breath: [cols=1;3,width=50%] |==== |Operator |Description |X |Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. |==== The other solution would be to open a request for prawn-table to support the :disable_wrap_by_char option on cells. We could allow this to be controlled via the Asciidoctor PDF theme. But prawn-table would actually need to honor this setting. To be honest, I don't really think autowidth has much of a place in PDF generation. It can work in a very limited set of circumstances, but you're always going to be better off setting the column ratios and table width. Best, -Dan On Mon, Oct 14, 2019 at 1:40 PM jtkorb [via Asciidoctor :: Discussion] <[hidden email]> wrote: Thanks--this solution worked for some of my tables, but (sorry for the trouble), here are two similar tables for which it didn't work:[options="header,autowidth"] |======================================================================= |Operator |Description |X |Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. Lots of text. |=======================================================================The output exhibits the same problem: "Operator" is split across two lines, with the second "r" on a line by itself. -- Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
Thanks for your advice. I've found autowidth handy to avoid embedding of column width knowledge in the markup, but, as you suggest, we can use column ratios and page width percentage as a workaround. (Autowidth seems to work well in HTML generation, but since we're trying to generate HTML and PDF (and, eventually, EPUB3) from one set of sources, it seems we should avoid autowidth altogether).
|
Administrator
|
That's precisely what I was going to suggest. So you've got it. Best, -Dan On Wed, Oct 16, 2019 at 1:43 PM jtkorb [via Asciidoctor :: Discussion] <[hidden email]> wrote: Thanks for your advice. I've found autowidth handy to avoid embedding of column width knowledge in the markup, but, as you suggest, we can use column ratios and page width percentage as a workaround. (Autowidth seems to work well in HTML generation, but since we're trying to generate HTML and PDF (and, eventually, EPUB3) from one set of sources, it seems we should avoid autowidth altogether). -- Dan Allen | @mojavelinux | https://twitter.com/mojavelinux |
Hello,
I've got exactly the same problem, using the java versions of Asciidoctor: asciidoctorj-2.3.1.jar asciidoctorj-pdf-1.5.3.pdf My source adoc is generated and I can't control column sizing, autowidth is my only option. Any idea ? thanks |
Administrator
|
Unfortunately, the prawn-table has yet to publish a new release, and sadly it appears the project is stalled. There's not much we can do about this. The workaround is to reconfigure your environment to use the code from the main branch of prawn-table (which is what we do in the test suite). -Dan On Mon, Jul 20, 2020 at 5:54 AM phgiraud [via Asciidoctor :: Discussion] <[hidden email]> wrote: Hello, -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
Thanks for your reply. How can you force a specific dependency? Under Gradle, we use:
runtime_asciidoctor ( 'org.asciidoctor:asciidoctorj:2.3.1', 'org.asciidoctor:asciidoctorj-pdf:1.5.3' ) And I guess that the prawn library comes as a dependency of asciidoctorj-pdf. But we can't control its version number. |
Administrator
|
It's more than just forcing a dependency. You'd have to run the dependency from source. I describe the approach in this issue: https://github.com/asciidoctor/asciidoctor-pdf/issues/650#issuecomment-258338060 Except you would be replacing prawn-table rather than asciidoctor-pdf. Best Regards, -Dan On Tue, Jul 21, 2020 at 2:03 AM phgiraud [via Asciidoctor :: Discussion] <[hidden email]> wrote: Thanks for your reply. How can you force a specific dependency? Under Gradle, we use: runtime_asciidoctor ( 'org.asciidoctor:asciidoctorj:2.3.1', 'org.asciidoctor:asciidoctorj-pdf:1.5.3' ) And I guess that the prawn library comes as a dependency of asciidoctorj-pdf. But we can't control its version number. -- Dan Allen (he, him, his) | @mojavelinux | https://twitter.com/mojavelinux |
Free forum by Nabble | Edit this page |