asciidoc tables - column widths

Eric esr at thyrsus.com
Sun Jan 3 18:02:40 UTC 2016


Hal Murray <hmurray at megapathdsl.net>:
> 
> Many of the tables in decode.html are hard to read.  I just hacked things a 
> bit, but I can't find a way to say what I want.  I can set the width of the 
> whole table as a fraction of the window and each column as a fraction of the 
> table width.
> 
> But I have no idea how wide the user has setup their window for the web page. 
>  Expressing things in fractions is good most of the time, but this seems to 
> be one of the nasty examples.  With a reasonable width window, the table only 
> needs a small fraction of the window.  But if the window is narrower, the 
> table needs the full width.
> 
> Is there any way to tell asciidoc to make this column wide enough to hold the 
> longest text in this column?
> 
> I'd be willing to describe widths in characters if that will help.

TL;DR I don't think there's any way to express column widths in absolute units.
IIRC the underlying XML-DocBook can't do that.

Here's the relevant documentation.  In the second bullet point of 23.4,
"output column width markup attributes" links to 23.7.

http://www.methods.co.nz/asciidoc/userguide.html#X70

   23.4. Column Specifiers

   Column specifiers define how columns are rendered and appear in the
   table cols attribute. A column specifier consists of an optional
   column multiplier followed by optional alignment, width and style
   values and is formatted like:

   [<multiplier>*][<align>][<width>][<style>]

   * All components are optional. The multiplier must be first and the
     style last. The order of <align> or <width> is not important.

   * Column <width> can be either an integer proportional value (1…) or a
     percentage (1%…100%). The default value is 1. To ensure portability
     across different backends, there is no provision for absolute column
     widths (not to be confused with output column width markup
     attributes which are available in both percentage and absolute
     units).

   * The <align> column alignment specifier is formatted like:

     [<horizontal>][.<vertical>]

     Where <horizontal> and <vertical> are one of the following characters:
     <, ^ or > which represent left, center and right horizontal alignment
     or top, middle and bottom vertical alignment respectively.

   * A <multiplier> can be used to specify repeated columns
     e.g. cols="4*<" specifies four left-justified columns. The default
     multiplier value is 1.

   * The <style> name specifies a table style to used to markup column
     cells (you can use the full style names if you wish but the first
     letter is normally sufficient).

   * Column specific styles are not applied to header rows.


http://www.methods.co.nz/asciidoc/userguide.html#X72

   23.7. Markup attributes

   AsciiDoc makes a number of attributes available to table markup
   templates and tags. Column specific attributes are available when
   substituting the colspec cell data tags.

   pageunits
      DocBook backend only. Specifies table column absolute width
      units. Defaults to *.

   pagewidth
      DocBook backend only. The nominal output page width in pageunit
      units. Used to calculate CALS tables absolute column and table
      widths. Defaults to 425.

   tableabswidth
      Integer value calculated from width and pagewidth attributes. In
      pageunit units.

   tablepcwidth
      Table width expressed as a percentage of the available
      width. Integer value (0..100).

   colabswidth
      Integer value calculated from cols column width, width and
      pagewidth attributes. In pageunit units.

   colpcwidth
      Column width expressed as a percentage of the table width. Integer
      value (0..100).

   colcount
      Total number of table columns.

   rowcount
      Total number of table rows.

   halign
      Horizontal cell content alignment: left, right or center.

   valign
      Vertical cell content alignment: top, bottom or middle.

   colnumber, colstart
      The number of the leftmost column occupied by the cell (1…).

   colend
   The number of the rightmost column occupied by the cell (1…).

   colspan
      Number of columns the cell should span.

   rowspan
      Number of rows the cell should span (1…).

   morerows
      Number of additional rows the cell should span (0…).



-- 
		<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>


More information about the devel mailing list