| 1 |
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Creating Tables</title><link rel="stylesheet" type="text/css" href="manual.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="home" href="index.html" title="DocBook to LaTeX Publishing" /><link rel="up" href="ch03.html" title="Chapter 3. Using dblatex" /><link rel="prev" href="sec-figinclude.html" title="Figure Inclusion" /><link rel="next" href="ch03s09.html" title="Correcting Poor Formatting" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Creating Tables</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="sec-figinclude.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Using dblatex</th><td width="20%" align="right"> <a accesskey="n" href="ch03s09.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="sec-table"></a>Creating Tables</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="sec-table.html#idp1134">Limitations</a></span></dt><dt><span class="section"><a href="sec-table.html#sec-table-width">Table Width</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1159">Tables without colwidth</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1165">Tables with mixed colspec</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1174">Tables with proportional and fixed colwidth</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1178">Tables with fixed colwidths</a></span></dt><dt><span class="section"><a href="sec-table.html#sec-autowidth">Automatic Column Width</a></span></dt><dt><span class="section"><a href="sec-table.html#sec-tabstyle">Informal Table LaTeX Styles</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1320">Tables with morerows</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1324">Landscape tables</a></span></dt><dt><span class="section"><a href="sec-table.html#idp1329">Smaller tables</a></span></dt><dt><span class="section"><a href="sec-table.html#sec-table-color">Coloured tables</a></span></dt><dt><span class="section"><a href="sec-table.html#sec-html-table">HTML Tables</a></span></dt></dl></div><p>DocBook tables can be quite complex, but <span class="command"><strong>dblatex</strong></span> |
| 3 |
should be able to drive most of cases thanks to the excellent newtbl |
| 4 |
implementation by David Hedley completely written in XSL.</p><p>Here is what is supported:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Columns without specified widths (<code class="sgmltag-element">colspec</code> without |
| 5 |
<code class="sgmltag-element">colwidth</code> attribute) have the same size.</p></li><li class="listitem"><p>A table width is always equal to the page width, if at least one column |
| 6 |
doesn't contain a fixed width attribute (e.g. colwidth=“12cm”).</p></li><li class="listitem"><p>Fixed column widths are supported (e.g. colwidth=“10cm”). The unit can |
| 7 |
be whatever is understood by latex (e.g. cm, em, in, pt).</p></li><li class="listitem"><p>Proportional column widths are supported (e.g. colwidth= “5*”). |
| 8 |
Combination of fixed and proportional width is supported too (e.g. |
| 9 |
colwidth=“5*+10cm”).</p></li><li class="listitem"><p>The <code class="sgmltag-element">morerows</code> attribute of a table entry |
| 10 |
(<code class="sgmltag-element">entry</code> element) is supported.</p></li><li class="listitem"><p>The <code class="sgmltag-element">namest</code> and <code class="sgmltag-element">nameend</code> attributes |
| 11 |
of a table entry (<code class="sgmltag-element">entry</code> element) are supported. It is |
| 12 |
possible to have a cell spanned on several columns.</p></li><li class="listitem"><p>The <code class="sgmltag-element">orient</code> table attribute is supported (portrait and |
| 13 |
landscape).</p></li><li class="listitem"><p>It is possible to have missing cell entries in a table.</p></li></ul></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1134"></a>Limitations</h3></div></div></div><p>Currently the following things are known to fail with tables: |
| 14 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Program listings and screens cannot be embedded in tables. Some other |
| 15 |
verbatim environments like litterallayout are allowed.</p></li></ul></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Footnotes in table cells can fail, especially if the footnote contains |
| 16 |
several paragraphs. Moreover they are lost is a float like a table.</p></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-table-width"></a>Table Width</h3></div></div></div><p>A table width is explicit when all the columns have a fixed size. In |
| 17 |
this case it is the sum of the colum widths. In the other cases (columns with |
| 18 |
no colwidth or proportional columns widths) the total table width is deduced |
| 19 |
by dblatex as follow: it looks for the Processing Instruction |
| 20 |
<code class="literal"><?dblatex table-with="<em class="replaceable"><code>width</code></em>" |
| 21 |
?></code> first, then the @width attribute, the |
| 22 |
<em class="parameter"><code>default.table.width</code></em> parameter, and finally use the page |
| 23 |
width.</p><p>A table width can be expressed as:</p><div class="itemizedlist"><a id="table-width-format"></a><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>A valid length (e.g. 15cm),</p></li><li class="listitem"><p>A percentage of the page width (e.g. 75%),</p></li><li class="listitem"><p>A keyword telling to apply an automatic column width (e.g. |
| 24 |
autowidth.all).</p></li></ul></div><p>The automatic column width setup is detailed in <a class="xref" href="sec-table.html#sec-autowidth" title="Automatic Column Width">the section called “Automatic Column Width”</a>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1159"></a>Tables without colwidth</h3></div></div></div><p>When none of the <code class="sgmltag-element">colspec</code> elements contains the |
| 25 |
<code class="sgmltag-element">colwidth</code> attribute, all the columns have the same size, and |
| 26 |
the table width is fixed to the maximum available size. Several examples of |
| 27 |
these tables are given<span class="phrase"> in the PDF version of this |
| 28 |
manual</span>.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1165"></a>Tables with mixed colspec</h3></div></div></div><p>A table can have <code class="sgmltag-element">colspec</code> elements containing |
| 29 |
<code class="sgmltag-element">colwidth</code> attribute mixed with <code class="sgmltag-element">colspec</code> |
| 30 |
elements without <code class="sgmltag-element">colwidth</code>. Here is an XML source |
| 31 |
example:</p><pre class="programlisting"> |
| 32 |
<informaltable> |
| 33 |
<tgroup cols="5" colsep="1" rowsep="1" align="left"> |
| 34 |
<colspec colname="c1"/> |
| 35 |
<colspec align="left" colwidth="4cm"/> |
| 36 |
<colspec align="right" colwidth="5cm"/> |
| 37 |
<colspec align="center"/> |
| 38 |
<colspec align="center" colwidth="3cm"/> |
| 39 |
<tbody> |
| 40 |
... |
| 41 |
</tbody> |
| 42 |
</tgroup> |
| 43 |
</informaltable> |
| 44 |
</pre><p>See the PDF version of this manual to see how it is |
| 45 |
rendered.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1174"></a>Tables with proportional and fixed colwidth</h3></div></div></div><p>Proportional column widths are supported. Here is an example:</p><pre class="programlisting"> |
| 46 |
<informaltable> |
| 47 |
<tgroup cols="5" colsep="1" rowsep="1" align="left"> |
| 48 |
<colspec colname="c1" colwidth="*"/> |
| 49 |
<colspec align="left" colwidth="2*"/> |
| 50 |
<colspec align="right" colwidth="3*"/> |
| 51 |
<colspec align="center"/> |
| 52 |
<colspec align="center" colwidth="3cm"/> |
| 53 |
<tbody> |
| 54 |
... |
| 55 |
</tbody> |
| 56 |
</tgroup> |
| 57 |
</informaltable> |
| 58 |
</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1178"></a>Tables with fixed colwidths</h3></div></div></div><p>All the columns can have fixed size, like this:</p><pre class="programlisting"><informaltable> |
| 59 |
<tgroup cols="4" colsep="1" rowsep="1" align="left"> |
| 60 |
<colspec colname="c1" colwidth="2cm"/> |
| 61 |
<colspec align="left" colwidth="2.5cm"/> |
| 62 |
<colspec align="right" colwidth="5cm"/> |
| 63 |
<colspec align="center" colwidth="3cm"/> |
| 64 |
<tbody> |
| 65 |
... |
| 66 |
</tbody> |
| 67 |
</tgroup> |
| 68 |
</informaltable> |
| 69 |
</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-autowidth"></a>Automatic Column Width</h3></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="sec-table.html#sec-newtbl-autowidth">Global Setting</a></span></dt><dt><span class="section"><a href="sec-table.html#sec-newtbl-autowidth2">Local Setting</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="sec-newtbl-autowidth"></a>Global Setting</h4></div></div></div><p>In the previous sections the columns widths are computed from a |
| 70 |
proportional basis, when no colwidth is specified or when the colwidths |
| 71 |
contain a star ("*"). Of course, a colwidth containing a fixed width |
| 72 |
incidently sets the column width with this size.</p><p>It is possible to change this sizing policy of not-fixed-width columns |
| 73 |
by playing with the <em class="parameter"><code>newtbl.autowidth</code></em> parameter. The |
| 74 |
parameter can take the following values: |
| 75 |
|
| 76 |
</p><div class="variablelist"><a id="autowidth-items"></a><dl class="variablelist"><dt><span class="term">default</span></dt><dd><p>The automatic width (that is, latex is in charge to size the column |
| 77 |
width) is applied only to columns not having a specified |
| 78 |
<code class="sgmltag-element">colspec</code> colwidth. It includes both undefined |
| 79 |
<code class="sgmltag-element">colspec</code>, and <code class="sgmltag-element">colspec</code> without the |
| 80 |
colwidth attribute.</p></dd><dt><span class="term">all</span></dt><dd><p>the automatic width is applied to any column, whether a colspec is |
| 81 |
provided or not.</p></dd></dl></div><p>By default the parameter is unset, and no automatic width is applied. |
| 82 |
Using automatic width is handy in some situations but there is no more control |
| 83 |
if the tables fit in the page or not, since in this case the column is as wide |
| 84 |
as its content, with no more paragraph breaking. The parameter is global for |
| 85 |
all the tables in the document.</p><p>You can also perform the same thing by setting the |
| 86 |
<em class="parameter"><code>default.table.width</code></em> parameter to |
| 87 |
<code class="literal">autowidth.default</code> or <code class="literal">autowidth.all</code> |
| 88 |
instead of using <em class="parameter"><code>newtbl.autowidth</code></em>.</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="sec-newtbl-autowidth2"></a>Local Setting</h4></div></div></div><p><a id="pi-autowidth"></a>If you want to apply an automatic width only to some |
| 89 |
specific tables you can put the Processing Instruction <code class="literal"><?dblatex |
| 90 |
table-with="autowidth.<em class="replaceable"><code>scope</code></em>" ?></code> in the |
| 91 |
related tables. The PI has precedence over the |
| 92 |
<em class="parameter"><code>newtbl.autowidth</code></em> parameter.</p><p>The <em class="replaceable"><code>scope</code></em> can take the same values and have |
| 93 |
the same effects than for the <em class="parameter"><code>newtbl.autowidth</code></em> |
| 94 |
parameter (<code class="literal">default</code> or <code class="literal">all</code>).</p><p><a id="pi-autowidth-column"></a>In addition to these keywords, <em class="parameter"><code>table.width</code></em> |
| 95 |
can also take for its value keywords of the form |
| 96 |
<code class="literal">autowidth.column: <em class="replaceable"><code>N</code></em><em class="replaceable"><code> ...</code></em></code>, where <em class="replaceable"><code>N</code></em> is the number of the |
| 97 |
column (counting from 1) which is to have its width automatically sized.</p><p>See the following example:</p><p> |
| 98 |
<a id="lst-table-autowidth"></a></p><pre class="programlisting"><informaltable><span class="bold"><strong><?dblatex table-width="autowidth.column: 1 3"?></strong></span> |
| 99 |
<tgroup cols="4" colsep="1" rowsep="1" align="left"> |
| 100 |
<colspec colname="c1"/> <!-- automatic width is applied to column #1 --> |
| 101 |
<colspec align="left" colwidth="*"/> |
| 102 |
<colspec align="right" colwidth="5cm"/> <!-- automatic width is applied to column #3 --> |
| 103 |
<colspec align="center" colwidth="3cm"/> |
| 104 |
... |
| 105 |
</informaltable> |
| 106 |
</pre><p> |
| 107 |
</p><p>Here are two other examples with the all and default scopes:</p><p>The following table has columns 1 and 2 sized by latex with |
| 108 |
autowidth.all:</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col align="left" class="c1" /><col align="left" /><col align="right" /><col align="center" /></colgroup><thead><tr><th align="left">Column 1</th><th align="left">Column 2</th><th align="right">Column 3</th><th align="center">Column 4</th></tr></thead><tbody><tr><td rowspan="4" align="left">cell on 4 lines |
| 109 |
</td><td align="left">simple cell |
| 110 |
</td><td rowspan="2" align="right">cell on 2 lines |
| 111 |
</td><td align="center">cell without morerow attribute |
| 112 |
</td></tr><tr><td align="left">cell in column 2 |
| 113 |
</td><td rowspan="2" align="center">cell on 2 |
| 114 |
lines |
| 115 |
</td></tr><tr><td rowspan="2" align="left">left aligned on 2 lines |
| 116 |
</td><td align="right">cell in line 3, column 3 |
| 117 |
</td></tr><tr><td align="right">4 cm column width |
| 118 |
</td><td align="center">last cell in column 4 |
| 119 |
</td></tr></tbody></table></div><p>It is written as follow:</p><p> |
| 120 |
</p><pre class="programlisting"><informaltable><span class="bold"><strong><?dblatex table-width="autowidth.all"?></strong></span> |
| 121 |
<tgroup cols="4" colsep="1" rowsep="1" align="left"> |
| 122 |
<colspec colname="c1"/> <!-- 'default' and 'all' apply on this column --> |
| 123 |
<colspec align="left" colwidth="*"/> <!-- only 'all' applies on this column --> |
| 124 |
<colspec align="right" colwidth="5cm"/> |
| 125 |
<colspec align="center" colwidth="3cm"/> |
| 126 |
... |
| 127 |
</informaltable> |
| 128 |
</pre><p> |
| 129 |
</p><p>The following table has only columns 1 sized by latex with |
| 130 |
autowidth.default:</p><div class="informaltable"><table class="informaltable" border="1"><colgroup><col align="left" class="c1" /><col align="left" /><col align="right" /><col align="center" /></colgroup><thead><tr><th align="left">Column 1</th><th align="left">Column 2</th><th align="right">Column 3</th><th align="center">Column 4</th></tr></thead><tbody><tr><td rowspan="4" align="left">cell on 4 lines |
| 131 |
</td><td align="left">simple cell |
| 132 |
</td><td rowspan="2" align="right">cell on 2 lines |
| 133 |
</td><td align="center">cell without morerow attribute |
| 134 |
</td></tr><tr><td align="left">cell in column 2 |
| 135 |
</td><td rowspan="2" align="center">cell on 2 |
| 136 |
lines |
| 137 |
</td></tr><tr><td rowspan="2" align="left">left aligned on 2 lines |
| 138 |
</td><td align="right">cell in line 3, column 3 |
| 139 |
</td></tr><tr><td align="right">4 cm column width |
| 140 |
</td><td align="center">last cell in column 4 |
| 141 |
</td></tr></tbody></table></div><p>The only difference is that the PI attribute value is |
| 142 |
autowidth.default:</p><pre class="programlisting"><informaltable><span class="bold"><strong><?dblatex table-width="autowidth.default"?></strong></span> |
| 143 |
<tgroup cols="4" colsep="1" rowsep="1" align="left"> |
| 144 |
<colspec colname="c1"/> <!-- 'default' and 'all' apply on this column --> |
| 145 |
<colspec align="left" colwidth="*"/> <!-- only 'all' applies on this column --> |
| 146 |
<colspec align="right" colwidth="5cm"/> |
| 147 |
<colspec align="center" colwidth="3cm"/> |
| 148 |
... |
| 149 |
</informaltable> |
| 150 |
</pre></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-tabstyle"></a>Informal Table LaTeX Styles</h3></div></div></div><p>By default <span class="command"><strong>dblatex</strong></span> translates an informal table to |
| 151 |
the LaTeX environment specified by the |
| 152 |
<em class="parameter"><code>table.default.tabstyle</code></em> parameter (usually |
| 153 |
<code class="literal">longtable</code>), but you can specify which Latex tabular |
| 154 |
environment to use, globally through the parameter, or per table through the |
| 155 |
<code class="sgmltag-element">tabstyle</code> attribute. Of course the |
| 156 |
<code class="sgmltag-element">tabstyle</code> attribute value is specific to dblatex. The |
| 157 |
supported values are:</p><p> |
| 158 |
</p><div class="variablelist"><dl class="variablelist"><dt><span class="term">longtable</span></dt><dd><p>The default table type used by dblatex when |
| 159 |
<em class="parameter"><code>table.default.tabstyle</code></em> is empty, in order to be able to |
| 160 |
split over several pages.</p></dd><dt><span class="term">tabular</span></dt><dd><p>The most usual table type. Such table can only be on a single |
| 161 |
page.</p></dd><dt><span class="term">tabularx</span></dt><dd><p>An advanced table type that allows to stretch column widths to the |
| 162 |
available remained page width. Such table can only be on a single page like |
| 163 |
for "tabular".</p></dd></dl></div><p> |
| 164 |
</p><p>The two following examples show how tabular and tabularx rendering |
| 165 |
differ when the automatic width feature is used. Here is the XML source |
| 166 |
code:</p><pre class="programlisting"><informaltable tabstyle="<span class="bold"><strong>tabular</strong></span>"> |
| 167 |
<?dblatex table-width="autowitdh.column: 1 3"?> |
| 168 |
<tgroup cols="5" colsep="1" rowsep="1" align="left"> |
| 169 |
<colspec colname="c1"/> |
| 170 |
<colspec align="left"/> |
| 171 |
<colspec align="right"/> |
| 172 |
<colspec align="center"/> |
| 173 |
... |
| 174 |
</tgroup> |
| 175 |
</informaltable> |
| 176 |
|
| 177 |
<informaltable tabstyle="<span class="bold"><strong>tabularx</strong></span>"> |
| 178 |
<?dblatex table-width="autowitdh.column: 1 3"?> |
| 179 |
<tgroup cols="5" colsep="1" rowsep="1" align="left"> |
| 180 |
<colspec colname="c1"/> |
| 181 |
<colspec align="left"/> |
| 182 |
<colspec align="right"/> |
| 183 |
<colspec align="center"/> |
| 184 |
... |
| 185 |
</tgroup> |
| 186 |
</informaltable> |
| 187 |
</pre><p>It is rendered as follow:</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1320"></a>Tables with morerows</h3></div></div></div><p>A table can contain entries that cover several lines. The following XML |
| 188 |
source contains an entry covering 4 lines:</p><pre class="programlisting"><informaltable> |
| 189 |
<tgroup cols="4" colsep="1" rowsep="1" align="left"> |
| 190 |
<colspec colname="c1" colwidth="*"/> |
| 191 |
... |
| 192 |
<tbody> |
| 193 |
<entry morerows="3">it covers 4 lines</entry> |
| 194 |
... |
| 195 |
</tbody> |
| 196 |
</tgroup> |
| 197 |
</informaltable> |
| 198 |
</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1324"></a>Landscape tables</h3></div></div></div><p>A table can be displayed in a lanscape format by using the |
| 199 |
<code class="sgmltag-element">orient</code> attribute. Here is an XML source example:</p><pre class="programlisting"><informaltable orient="land"> |
| 200 |
<tgroup cols="5" colsep="1" rowsep="1" align="left"> |
| 201 |
<colspec colname="c1" colwidth="*"/> |
| 202 |
... |
| 203 |
<tbody> |
| 204 |
... |
| 205 |
</tbody> |
| 206 |
</tgroup> |
| 207 |
</informaltable> |
| 208 |
</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idp1329"></a>Smaller tables</h3></div></div></div><p>For big tables it can be usefull to have smaller text, so that the table |
| 209 |
is not too large or too long and it can be displayed within a page. It is |
| 210 |
possible to specify smaller table text by using the <code class="sgmltag-element">role</code> |
| 211 |
attribute of the elements <code class="sgmltag-element">table</code> or |
| 212 |
<code class="sgmltag-element">informaltable</code>.</p><p>The values and the “role” dedicated to this attribute are specific to |
| 213 |
dblatex, but it is compliant with the DocBook specification because in general |
| 214 |
the <code class="sgmltag-element">role</code> attribute purpose is never defined.</p><p>The available text size definitions supported by <code class="sgmltag-element">role</code> |
| 215 |
are directly taken from LaTeX:</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>small,</p></li><li class="listitem"><p>footnotesize,</p></li><li class="listitem"><p>scriptsize,</p></li><li class="listitem"><p>tiny.</p></li></ul></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-table-color"></a>Coloured tables</h3></div></div></div><p>You can color all the table by setting its <code class="sgmltag-element">bgcolor</code> |
| 216 |
attribute.</p><p>You can also color only some cells by using the Processing Instruction |
| 217 |
<code class="literal"><?dblatex bgcolor="color"?></code>. The PI can apply to |
| 218 |
columns when put in a <code class="sgmltag-element">colspec</code>, to rows when put at the |
| 219 |
beginning of a <code class="sgmltag-element">row</code>, or to cells when put in a |
| 220 |
<code class="sgmltag-element">entry</code>.</p><p>The entry colour has precedence over the row colour, that has precedence |
| 221 |
over the column colour, that has precedence over the table colour.</p><p><a id="table-color-format"></a>The color can be expressed in hexadecimal |
| 222 |
notation like for HTML (e.g. <code class="literal">#C0C0C0</code>) or in a syntax |
| 223 |
understood by the <code class="filename">colortbl</code> latex package.</p><p>Here is a<span class="phrase"> PDF |
| 224 |
output</span> example.</p><div class="mediaobject" align="center"><img src="img-tbl-color.png" align="middle" /></div><p>This table is coded like this:</p><pre class="programlisting"><informaltable id="tbl-color" bgcolor="{yellow}"> |
| 225 |
<tgroup cols="4" colsep="1" rowsep="1" align="left"> |
| 226 |
<colspec colname="c1" colwidth="2cm"/> |
| 227 |
<colspec align="left" colwidth="2.5cm"><?dblatex bgcolor="#00FF00"?></colspec> |
| 228 |
<colspec align="right" colwidth="5cm"/> |
| 229 |
<colspec align="center" colwidth="3cm"/> |
| 230 |
<thead> |
| 231 |
<row> |
| 232 |
<entry>Column 1</entry><entry>Column 2</entry> |
| 233 |
<entry>Column 3</entry><entry>Column 4</entry> |
| 234 |
</row> |
| 235 |
</thead> |
| 236 |
<tbody> |
| 237 |
<row> |
| 238 |
<entry>yellow</entry><entry>green column</entry> |
| 239 |
<entry>yellow</entry><entry>yellow</entry> |
| 240 |
</row> |
| 241 |
<row> |
| 242 |
<?dblatex bgcolor="{blue}"?> |
| 243 |
<entry>blue row</entry> |
| 244 |
<entry><?dblatex bgcolor="{red}"?>red cell</entry> |
| 245 |
<entry>blue row</entry><entry>blue row</entry> |
| 246 |
</row> |
| 247 |
<row> |
| 248 |
<entry>yellow</entry><entry>green column</entry> |
| 249 |
<entry>yellow</entry> |
| 250 |
<entry><?dblatex bgcolor="[gray]{0.8}"?>gray</entry> |
| 251 |
</row> |
| 252 |
</tbody> |
| 253 |
</tgroup> |
| 254 |
</informaltable> |
| 255 |
</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="sec-html-table"></a>HTML Tables</h3></div></div></div><p>Since version 0.3.2 dblatex supports HTML tables. Some features are |
| 256 |
handled differently from CALS tables as illustrated by the following HTML |
| 257 |
table source example:</p><pre class="programlisting"><table border="1" width="100%" rules="all"<a id="co-htmltbl-rules"></a><span><img src="images/callouts/1.png" alt="1" border="0" /></span>> |
| 258 |
<caption>An HTML Table</caption><a id="co-htmltbl-title"></a><span><img src="images/callouts/2.png" alt="2" border="0" /></span> |
| 259 |
<colgroup span="2" valign="top" align="right"/> |
| 260 |
<?dblatex bgcolor="red"?><a id="co-htmltbl-bgcolor1"></a><span><img src="images/callouts/3.png" alt="3" border="0" /></span> |
| 261 |
</colgroup> |
| 262 |
<colgroup valign="bottom" align="left" width="5%"<a id="co-htmltbl-widthpct"></a><span><img src="images/callouts/4.png" alt="4" border="0" /></span>> |
| 263 |
<col align="right" span="2"/> |
| 264 |
<col valign="top"/> |
| 265 |
</colgroup> |
| 266 |
<colgroup bgcolor="yellow" width="0*"<a id="co-htmltbl-autowidth"></a><span><img src="images/callouts/5.png" alt="5" border="0" /></span>><?dblatex bgcolor="yellow"?></colgroup> |
| 267 |
<colgroup valign="bottom" align="left" width="15%"/> |
| 268 |
<colgroup valign="bottom" align="left" width="10%"/> |
| 269 |
<thead> |
| 270 |
<tr> <td width="10%">Head A1</td><td>Head B1</td><td>Head C1</td> </tr> |
| 271 |
</thead> |
| 272 |
<tfoot> |
| 273 |
<tr> <td width="10%">Foot A1</td><td>Foot B1</td><td>Foot C1</td> </tr> |
| 274 |
</tfoot> |
| 275 |
|
| 276 |
<tr> |
| 277 |
<td width="10%">A1</td><td>B1</td><td>C1</td> |
| 278 |
</tr> |
| 279 |
<tr> |
| 280 |
<td>A2</td><td bgcolor="yellow">B2</td><td colspan="3" rowspan="3">C-E2</td><td>F2</td> |
| 281 |
</tr> |
| 282 |
<tr> |
| 283 |
<td>A3</td><td width="25.3"<a id="co-htmltbl-widthfix"></a><span><img src="images/callouts/6.png" alt="6" border="0" /></span>>B3</td><td>F3</td><td rowspan="2">G3</td><td rowspan="3">H3</td> |
| 284 |
</tr> |
| 285 |
<tr> |
| 286 |
<td>A4</td><td>B4</td><td>F4</td><td>G4</td> |
| 287 |
</tr> |
| 288 |
<tr> |
| 289 |
<td>A5</td><td>B5</td><td width="5%">C5</td><td>D5</td> |
| 290 |
</tr> |
| 291 |
<tr bgcolor="blue"<a id="co-htmltbl-bgcolorp"></a><span><img src="images/callouts/7.png" alt="7" border="0" /></span>> |
| 292 |
<td>A6</td><td>B6</td><td>C6</td><td>D6</td><td>E6</td><td bgcolor="green"<a id="co-htmltbl-bgcolorp"></a><span><img src="images/callouts/7.png" alt="7" border="0" /></span>>F6</td> |
| 293 |
</tr> |
| 294 |
</table></pre><div class="calloutlist"><table border="0" summary="Callout list"><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-rules"><span><img src="images/callouts/1.png" alt="1" border="0" /></span></a> </p></td><td valign="top" align="left"><p>The cell borders are specified through the table <code class="sgmltag-element">rules</code> attribute, and not by any |
| 295 |
<code class="sgmltag-element">rowsep</code> and <code class="sgmltag-element">colsep</code> attributes. Therefore |
| 296 |
it is not possible to set the borders of an individual cell. If no <code class="sgmltag-element">rules</code> attribute is provided the default setup |
| 297 |
defined by <em class="parameter"><code>default.table.rules</code></em> parameter is |
| 298 |
used.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-title"><span><img src="images/callouts/2.png" alt="2" border="0" /></span></a> </p></td><td valign="top" align="left"><p>The title of a formal HTML table is set through the |
| 299 |
<code class="sgmltag-element">caption</code> element, because the <code class="sgmltag-element">title</code> |
| 300 |
element is not available.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-bgcolor1"><span><img src="images/callouts/3.png" alt="3" border="0" /></span></a> </p></td><td valign="top" align="left"><p>The cell background colors can be set directly with the bgcolor |
| 301 |
attribute in <code class="sgmltag-element">row</code> (for an entire row color setting), |
| 302 |
<code class="sgmltag-element">th</code>, or <code class="sgmltag-element">td</code>, but the dblatex bgcolor |
| 303 |
Processing Instruction is required in <code class="sgmltag-element">colgroup</code> or |
| 304 |
<code class="sgmltag-element">col</code> to set a column color.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-widthpct"><span><img src="images/callouts/4.png" alt="4" border="0" /></span></a> </p></td><td valign="top" align="left"><p>The relative widths can be expressed as a percentage. The proportional |
| 305 |
syntax (e.g. "3*") is still available in <code class="sgmltag-element">colgroup</code>s.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-autowidth"><span><img src="images/callouts/5.png" alt="5" border="0" /></span></a> </p></td><td valign="top" align="left"><p>To specify that a column must be as wide as its content, there is no |
| 306 |
need to use the dblatex autowidth Processing Instruction. You just need to set |
| 307 |
the related colgroup width attribute to "0*".</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-widthfix"><span><img src="images/callouts/6.png" alt="6" border="0" /></span></a> </p></td><td valign="top" align="left"><p>The fixed widths must be expressed as numbers, and the implicit unit is |
| 308 |
the point ("pt"). You cannot set a width expressed in a unit like inchs |
| 309 |
("in"), centimeters ("cm") and so on.</p></td></tr><tr><td width="5%" valign="top" align="left"><p><a href="#co-htmltbl-bgcolorp"><span><img src="images/callouts/7.png" alt="7" border="0" /></span></a> </p></td><td valign="top" align="left"><p>The closest enclosing element attribute has precedence over ancestor |
| 310 |
attributes. This applies to background color too.</p></td></tr></table></div><p>This source example is rendered as follow:</p><div class="mediaobject" align="center"><img src="img-tbl-html.png" align="middle" /></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="sec-figinclude.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03s09.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> |
| 311 |
Figure Inclusion |
| 312 |
</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Correcting Poor Formatting</td></tr></table></div></body></html> |