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