1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
<!ENTITY __table-eg00__g468a1wg SYSTEM "table-eg00.xml">
<!ENTITY __table-eg01__g468a1wg SYSTEM "table-eg01.xml">
<!ENTITY __table-eg02__g468a1wh SYSTEM "table-eg02.xml">
<!ENTITY __table-style1 SYSTEM "table-style1.xml">
<!ENTITY __table-style2 SYSTEM "table-style2.xml">
]>
<section id="sec-table" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Creating Tables</title>
<para>DocBook tables can be quite complex, but <command>dblatex</command>
should be able to drive most of cases thanks to the excellent newtbl
implementation by David Hedley completely written in XSL.</para>
<para>Here is what is supported:</para>
<itemizedlist>
<listitem>
<para>Columns without specified widths (<sgmltag>colspec</sgmltag> without
<sgmltag>colwidth</sgmltag> attribute) have the same size.</para>
</listitem>
<listitem>
<para>A table width is always equal to the page width, if at least one column
doesn't contain a fixed width attribute (e.g. colwidth=“12cm”).</para>
</listitem>
<listitem>
<para>Fixed column widths are supported (e.g. colwidth=“10cm”). The unit can
be whatever is understood by latex (e.g. cm, em, in, pt).</para>
</listitem>
<listitem>
<para>Proportional column widths are supported (e.g. colwidth= “5*”).
Combination of fixed and proportional width is supported too (e.g.
colwidth=“5*+10cm”).</para>
</listitem>
<listitem>
<para>The <sgmltag>morerows</sgmltag> attribute of a table entry
(<sgmltag>entry</sgmltag> element) is supported.</para>
</listitem>
<listitem>
<para>The <sgmltag>namest</sgmltag> and <sgmltag>nameend</sgmltag> attributes
of a table entry (<sgmltag>entry</sgmltag> element) are supported. It is
possible to have a cell spanned on several columns.</para>
</listitem>
<listitem>
<para>The <sgmltag>orient</sgmltag> table attribute is supported (portrait and
landscape).</para>
</listitem>
<listitem>
<para>It is possible to have missing cell entries in a table.</para>
</listitem>
</itemizedlist>
<section>
<title>Limitations</title>
<para>Currently the following things are known to fail with tables:
<itemizedlist>
<listitem>
<para>Program listings and screens cannot be embedded in tables. Some other
verbatim environments like litterallayout are allowed.</para>
</listitem>
</itemizedlist><itemizedlist>
<listitem>
<para>Footnotes in table cells can fail, especially if the footnote contains
several paragraphs. Moreover they are lost is a float like a table.</para>
</listitem>
</itemizedlist></para>
</section>
<section id="sec-table-width">
<title>Table Width</title>
<para>A table width is explicit when all the columns have a fixed size. In
this case it is the sum of the colum widths. In the other cases (columns with
no colwidth or proportional columns widths) the total table width is deduced
by dblatex as follow: it looks for the Processing Instruction
<literal><?dblatex table-with="<replaceable>width</replaceable>"
?></literal> first, then the @width attribute, the
<parameter>default.table.width</parameter> parameter, and finally use the page
width.</para>
<para>A table width can be expressed as:</para>
<itemizedlist>
<listitem>
<para>A valid length (e.g. 15cm),</para>
</listitem>
<listitem>
<para>A percentage of the page width (e.g. 75%),</para>
</listitem>
<listitem>
<para>A keyword telling to apply an automatic column width (e.g.
autowidth.all). See <xref linkend="sec-autowidth" /> for more details.</para>
</listitem>
</itemizedlist>
</section>
<section>
<title>Tables without colwidth</title>
<para>When none of the <sgmltag>colspec</sgmltag> elements contains the
<sgmltag>colwidth</sgmltag> attribute, all the columns have the same size, and
the table width is fixed to the maximum available size. Several examples of
these tables are given<phrase output="html"> in the PDF version of this
manual</phrase>.</para>
<para output="pdf">
&__table-eg00__g468a1wg;
&__table-eg01__g468a1wg;
&__table-eg02__g468a1wh;
</para>
</section>
<section>
<title>Tables with mixed colspec</title>
<para>A table can have <sgmltag>colspec</sgmltag> elements containing
<sgmltag>colwidth</sgmltag> attribute mixed with <sgmltag>colspec</sgmltag>
elements without <sgmltag>colwidth</sgmltag>. Here is an XML source
example:</para>
<programlisting>
<informaltable>
<tgroup cols="5" colsep="1" rowsep="1" align="left">
<colspec colname="c1"/>
<colspec align="left" colwidth="4cm"/>
<colspec align="right" colwidth="5cm"/>
<colspec align="center"/>
<colspec align="center" colwidth="3cm"/>
<tbody>
...
</tbody>
</tgroup>
</informaltable>
</programlisting>
<para output="pdf">It is rendered like this: <xi:include href="table-eg1.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" /></para>
<para output="html">See the PDF version of this manual to see how it is
rendered.</para>
</section>
<section>
<title>Tables with proportional and fixed colwidth</title>
<para>Proportional column widths are supported. Here is an example:</para>
<programlisting>
<informaltable>
<tgroup cols="5" colsep="1" rowsep="1" align="left">
<colspec colname="c1" colwidth="*"/>
<colspec align="left" colwidth="2*"/>
<colspec align="right" colwidth="3*"/>
<colspec align="center"/>
<colspec align="center" colwidth="3cm"/>
<tbody>
...
</tbody>
</tgroup>
</informaltable>
</programlisting>
<para output="pdf">It gives this table: <xi:include href="table-eg2.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" /></para>
</section>
<section>
<title>Tables with fixed colwidths</title>
<para>All the columns can have fixed size, like this:</para>
<programlisting><informaltable>
<tgroup cols="4" colsep="1" rowsep="1" align="left">
<colspec colname="c1" colwidth="2cm"/>
<colspec align="left" colwidth="2.5cm"/>
<colspec align="right" colwidth="5cm"/>
<colspec align="center" colwidth="3cm"/>
<tbody>
...
</tbody>
</tgroup>
</informaltable>
</programlisting>
<para output="pdf">It gives the following table: <xi:include
href="table-eg3.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /></para>
</section>
<section id="sec-autowidth">
<title>Automatic Column Width</title>
<section id="sec-newtbl-autowidth">
<title>Global Setting</title>
<para>In the previous sections the columns widths are computed from a
proportional basis, when no colwidth is specified or when the colwidths
contain a star ("*"). Of course, a colwidth containing a fixed width
incidently sets the column width with this size.</para>
<para>It is possible to change this sizing policy of not-fixed-width columns
by playing with the <parameter>newtbl.autowidth</parameter> parameter. The
parameter can take the following values: <variablelist>
<varlistentry>
<term>default</term>
<listitem>
<para>The automatic width (that is, latex is in charge to size the column
width) is applied only to columns not having a specified
<sgmltag>colspec</sgmltag> colwidth. It includes both undefined
<sgmltag>colspec</sgmltag>, and <sgmltag>colspec</sgmltag> without the
colwidth attribute.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>all</term>
<listitem>
<para>the automatic width is applied to any column, whatever a colspec is
provided or not.</para>
</listitem>
</varlistentry>
</variablelist></para>
<para>By default the parameter is unset, and no automatic width is applied.
Using automatic width is handy in some situations but there is no more control
if the tables fit in the page or not, since in this case the column is as wide
as its content, with no more paragraph breaking. The parameter is global for
all the tables in the document.</para>
<para>You can also perform the same thing by setting the
<parameter>default.table.width</parameter> parameter to
<literal>autowidth.default</literal> or <literal>autowidth.all</literal>
instead of using <parameter>newtbl.autowidth</parameter>.</para>
</section>
<section id="sec-newtbl-autowidth2">
<title>Local Setting</title>
<para>If you want to apply an automatic width only to some specific tables you
can put the Processing Instruction <literal><?dblatex
table-with="autowidth.<replaceable>scope</replaceable>" ?></literal> in the
related tables. The PI has precedence over the
<parameter>newtbl.autowidth</parameter> parameter.</para>
<para>The <replaceable>scope</replaceable> can take the same values and have
the same effects than for the <parameter>newtbl.autowidth</parameter>
parameter (<literal>default</literal> or <literal>all</literal>) and it can
take another value: <literal>column</literal>. When set to
<literal>column</literal>, the number of the columns subject to automatic
width must be specified after a colon separator, as shown by the following
example:</para>
<para>
<programlisting><informaltable><emphasis role="bold"><?dblatex table-width="autowidth.column: 1 3"?></emphasis>
<tgroup cols="4" colsep="1" rowsep="1" align="left">
<colspec colname="c1"/> <!-- automatic width is applied to column #1 -->
<colspec align="left" colwidth="*"/>
<colspec align="right" colwidth="5cm"/> <!-- automatic width is applied to column #3 -->
<colspec align="center" colwidth="3cm"/>
...
</informaltable>
</programlisting>
</para>
<para>Here are two other examples with the all and default scopes:</para>
<para>The following table has columns 1 and 2 sized by latex with
autowidth.all:</para>
<xi:include href="table-auto1.xml" />
<para>It is written as follow:</para>
<para>
<programlisting><informaltable><emphasis role="bold"><?dblatex table-width="autowidth.all"?></emphasis>
<tgroup cols="4" colsep="1" rowsep="1" align="left">
<colspec colname="c1"/> <!-- 'default' and 'all' apply on this column -->
<colspec align="left" colwidth="*"/> <!-- only 'all' applies on this column -->
<colspec align="right" colwidth="5cm"/>
<colspec align="center" colwidth="3cm"/>
...
</informaltable>
</programlisting>
</para>
<para>The following table has only columns 1 sized by latex with
autowidth.default:</para>
<xi:include href="table-auto2.xml" />
<para>The only difference is that the PI attribute value is
autowidth.default:</para>
<programlisting><informaltable><emphasis role="bold"><?dblatex table-width="autowidth.default"?></emphasis>
<tgroup cols="4" colsep="1" rowsep="1" align="left">
<colspec colname="c1"/> <!-- 'default' and 'all' apply on this column -->
<colspec align="left" colwidth="*"/> <!-- only 'all' applies on this column -->
<colspec align="right" colwidth="5cm"/>
<colspec align="center" colwidth="3cm"/>
...
</informaltable>
</programlisting>
</section>
</section>
<section id="sec-tabstyle">
<title>Informal Table LaTeX Styles</title>
<para>By default <command>dblatex</command> translates an informal table to
the LaTeX environment specified by the
<parameter>table.default.tabstyle</parameter> parameter (usually
<literal>longtable</literal>), but you can specify which Latex tabular
environment to use, globally through the parameter, or per table through the
<sgmltag>tabstyle</sgmltag> attribute. Of course the
<sgmltag>tabstyle</sgmltag> attribute value is specific to dblatex. The
supported values are:</para>
<para>
<variablelist>
<varlistentry>
<term>longtable</term>
<listitem>
<para>The default table type used by dblatex when
<parameter>table.default.tabstyle</parameter> is empty, in order to be able to
split over several pages.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>tabular</term>
<listitem>
<para>The most usual table type. Such table can only be on a single
page.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>tabularx</term>
<listitem>
<para>An advanced table type that allows to stretch column widths to the
available remained page width. Such table can only be on a single page like
for "tabular".</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>The two following examples show how tabular and tabularx rendering
differ when the automatic width feature is used. Here is the XML source
code:</para>
<programlisting><informaltable tabstyle="<emphasis role="bold">tabular</emphasis>">
<?dblatex table-width="autowitdh.column: 1 3"?>
<tgroup cols="5" colsep="1" rowsep="1" align="left">
<colspec colname="c1"/>
<colspec align="left"/>
<colspec align="right"/>
<colspec align="center"/>
...
</tgroup>
</informaltable>
<informaltable tabstyle="<emphasis role="bold">tabularx</emphasis>">
<?dblatex table-width="autowitdh.column: 1 3"?>
<tgroup cols="5" colsep="1" rowsep="1" align="left">
<colspec colname="c1"/>
<colspec align="left"/>
<colspec align="right"/>
<colspec align="center"/>
...
</tgroup>
</informaltable>
</programlisting>
<para>It is rendered as follow:</para>
<para output="pdf">
&__table-style1;
&__table-style2;
</para>
</section>
<section>
<title>Tables with morerows</title>
<para>A table can contain entries that cover several lines. The following XML
source contains an entry covering 4 lines:</para>
<programlisting><informaltable>
<tgroup cols="4" colsep="1" rowsep="1" align="left">
<colspec colname="c1" colwidth="*"/>
...
<tbody>
<entry morerows="3">it covers 4 lines</entry>
...
</tbody>
</tgroup>
</informaltable>
</programlisting>
<para output="pdf">Here is an example of table containing several entries with
morerows attribute: <xi:include href="table-eg4.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" /></para>
</section>
<section>
<title>Landscape tables</title>
<para>A table can be displayed in a lanscape format by using the
<sgmltag>orient</sgmltag> attribute. Here is an XML source example:</para>
<programlisting><informaltable orient="land">
<tgroup cols="5" colsep="1" rowsep="1" align="left">
<colspec colname="c1" colwidth="*"/>
...
<tbody>
...
</tbody>
</tgroup>
</informaltable>
</programlisting>
<para output="pdf">Here is how it is displayed. <xi:include
href="table-land.xml" xmlns:xi="http://www.w3.org/2001/XInclude" /></para>
</section>
<section>
<title>Smaller tables</title>
<para>For big tables it can be usefull to have smaller text, so that the table
is not too large or too long and it can be displayed within a page. It is
possible to specify smaller table text by using the <sgmltag>role</sgmltag>
attribute of the elements <sgmltag>table</sgmltag> or
<sgmltag>informaltable</sgmltag>.</para>
<para>The values and the “role” dedicated to this attribute are specific to
dblatex, but it is compliant with the DocBook specification because in general
the <sgmltag>role</sgmltag> attribute purpose is never defined.</para>
<para>The available text size definitions supported by <sgmltag>role</sgmltag>
are directly taken from LaTeX:</para>
<itemizedlist>
<listitem>
<para>small,</para>
</listitem>
<listitem>
<para>footnotesize,</para>
</listitem>
<listitem>
<para>scriptsize,</para>
</listitem>
<listitem>
<para>tiny.</para>
</listitem>
</itemizedlist>
<para output="pdf">Here are examples for each size. <xi:include
href="table-small1.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="table-small2.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" /> <xi:include
href="table-small3.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="table-small4.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" /></para>
</section>
<section>
<title>Coloured tables</title>
<para>You can color all the table by setting its <sgmltag>bgcolor</sgmltag>
attribute.</para>
<para>You can also color only some cells by using the Processing Instruction
<literal><?dblatex bgcolor="color"?></literal>. The PI can apply to
columns when put in a <sgmltag>colspec</sgmltag>, to rows when put at the
beginning of a <sgmltag>row</sgmltag>, or to cells when put in a
<sgmltag>entry</sgmltag>.</para>
<para>The entry colour has precedence over the row colour, that has precedence
over the column colour, that has precedence over the table colour.</para>
<para>The color can be expressed in hexadecimal notation like for HTML (e.g.
<literal>#C0C0C0</literal>) or in a syntax understood by the
<filename>colortbl</filename> latex package.</para>
<para>Here is a<phrase output="pdf">n</phrase><phrase output="html"> PDF
output</phrase> example.</para>
<para output="pdf">
<xi:include href="coloured.xml" />
</para>
<!-- The image img-tbl-color.png was built with the command line:
../tools/imagefrom manual.xml tbl-color
-->
<mediaobject output="html">
<imageobject>
<imagedata align="center" fileref="img-tbl-color" />
</imageobject>
</mediaobject>
<para>This table is coded like this:</para>
<!-- To comment before editing with XXE
-->
<programlisting><xi:include href="coloured.xml" parse="text"/></programlisting>
</section>
<section id="sec-html-table">
<title>HTML Tables</title>
<para>Since version 0.3.2 dblatex supports HTML tables. Some features are
handled differently from CALS tables as illustrated by the following HTML
table source example:</para>
<programlisting language="HTML"><table border="1" width="100%" rules="all"<co
id="co-htmltbl-rules" />>
<caption>An HTML Table</caption><co id="co-htmltbl-title" />
<colgroup span="2" valign="top" align="right"/>
<?dblatex bgcolor="red"?><co id="co-htmltbl-bgcolor1" />
</colgroup>
<colgroup valign="bottom" align="left" width="5%"<co
id="co-htmltbl-widthpct" />>
<col align="right" span="2"/>
<col valign="top"/>
</colgroup>
<colgroup bgcolor="yellow" width="0*"<co id="co-htmltbl-autowidth" />><?dblatex bgcolor="yellow"?></colgroup>
<colgroup valign="bottom" align="left" width="15%"/>
<colgroup valign="bottom" align="left" width="10%"/>
<thead>
<tr> <td width="10%">Head A1</td><td>Head B1</td><td>Head C1</td> </tr>
</thead>
<tfoot>
<tr> <td width="10%">Foot A1</td><td>Foot B1</td><td>Foot C1</td> </tr>
</tfoot>
<tr>
<td width="10%">A1</td><td>B1</td><td>C1</td>
</tr>
<tr>
<td>A2</td><td bgcolor="yellow">B2</td><td colspan="3" rowspan="3">C-E2</td><td>F2</td>
</tr>
<tr>
<td>A3</td><td width="25.3"<co id="co-htmltbl-widthfix" />>B3</td><td>F3</td><td rowspan="2">G3</td><td rowspan="3">H3</td>
</tr>
<tr>
<td>A4</td><td>B4</td><td>F4</td><td>G4</td>
</tr>
<tr>
<td>A5</td><td>B5</td><td width="5%">C5</td><td>D5</td>
</tr>
<tr bgcolor="blue"<co id="co-htmltbl-bgcolorp" />>
<td>A6</td><td>B6</td><td>C6</td><td>D6</td><td>E6</td><td bgcolor="green"<coref
linkend="co-htmltbl-bgcolorp" />>F6</td>
</tr>
</table></programlisting>
<calloutlist>
<callout arearefs="co-htmltbl-rules">
<para>The cell borders are specified through the table <sgmltag
role="attribute">rules</sgmltag> attribute, and not by any
<sgmltag>rowsep</sgmltag> and <sgmltag>colsep</sgmltag> attributes. Therefore
it is not possible to set the borders of an individual cell. If no <sgmltag
role="attribute">rules</sgmltag> attribute is provided the default setup
defined by <parameter>default.table.rules</parameter> parameter is
used.</para>
</callout>
<callout arearefs="co-htmltbl-title">
<para>The title of a formal HTML table is set through the
<sgmltag>caption</sgmltag> element, because the <sgmltag>title</sgmltag>
element is not available.</para>
</callout>
<callout arearefs="co-htmltbl-bgcolor1">
<para>The cell background colors can be set directly with the bgcolor
attribute in <sgmltag>row</sgmltag> (for an entire row color setting),
<sgmltag>th</sgmltag>, or <sgmltag>td</sgmltag>, but the dblatex bgcolor
Processing Instruction is required in <sgmltag>colgroup</sgmltag> or
<sgmltag>col</sgmltag> to set a column color.</para>
</callout>
<callout arearefs="co-htmltbl-widthpct">
<para>The relative widths can be expressed as a percentage. The proportional
syntax (e.g. "3*") is still available in <sgmltag>colgroup</sgmltag>s.</para>
</callout>
<callout arearefs="co-htmltbl-autowidth">
<para>To specify that a column must be as wide as its content, there is no
need to use the dblatex autowidth Processing Instruction. You just need to set
the related colgroup width attribute to "0*".</para>
</callout>
<callout arearefs="co-htmltbl-widthfix">
<para>The fixed widths must be expressed as numbers, and the implicit unit is
the point ("pt"). You cannot set a width expressed in a unit like inchs
("in"), centimeters ("cm") and so on.</para>
</callout>
<callout arearefs="co-htmltbl-bgcolorp">
<para>The closest enclosing element attribute has precedence over ancestor
attributes. This applies to background color too.</para>
</callout>
</calloutlist>
<para>This source example is rendered as follow:</para>
<para output="pdf">
<xi:include href="table-html.xml" />
</para>
<!-- The image img-tbl-html.png was built with the command line:
../tools/imagefrom manual.xml tbl-html
-->
<mediaobject output="html">
<imageobject>
<imagedata align="center" fileref="img-tbl-html" />
</imageobject>
</mediaobject>
</section>
</section>
|