Tables » Historie » Revision 3
Revision 2 (Martin Kraetke, 22.12.2021 17:58) → Revision 3/5 (Martin Kraetke, 22.12.2021 18:02)
h1. Tables For table rendering, we use *htmltabs* ("link to repository":https://gitlab.le-tex.de/htmltabs/htmltabs/-/tree/master/releases) developed by _Patrick Schulz_ rather than other table packages known from TeX. h2. Include htmltabs Add this line to the preamble <pre> \usepackage{htmltabs} </pre> h2. Table Markup h3. Mapping XHTML -> LaTeX The htmltabs markup reflects the structure of a HTML table. |_. XML |_. TeX |_. Description | |<table>…</table>|\begin{htmltab}[…] … \end{htmltab}| | |<col />|\HTcol[…]| vor thead | |<colgroup>…</colgroup>|\HTcolgroup[…]{…}| before thead | |<thead>…</thead>|\begin{thead}[…] … \end{thead}| after tbody | |<tfoot>…</tfoot>|\begin{tfoot}[…] … \end{tfoot}| after tbody, before thead | |<tbody>…</tbody>|\begin{tbody}[…] … \end{tbody}| | |<tr>…</tr>|\HTtr[…]{…}| | |<td>…</td>|\HTtd[…]{…}| | |<th>…</th>|\HTth[…]{…}| | It is important that the grid is kept: for x columns and y rows (taking into account colspan and rowspan) there must be x × y cells. h3. Attributes and CSS Properties The following "attributes" can be included in the optional argument (if empty, omit) of all "elements": * @style={}@ contains CSS property-value pairs, syntax within the curly braces is as in XML, e.g. <pre><code class="text">\HTtd[style={<CSS-Eigenschaft-1>:<CSS-Wert-1>; <CSS-Eigenschaft-2>: <CSS-Wert-2>; … }]{<Inhalt>}</code></pre> The CSS properties in the HTML can be transferred directly to TeX. The same applies to the environments: <pre><code class="text">\begin{htmltab}[style={<CSS-Eigenschaft-1>:<CSS-Wert-1>; <CSS-Eigenschaft-2>: <CSS-Wert-2>; … }] …</code></pre> Currently implemented CSS properties: ** @margin@, with or without @-top@, @-left@, @-right@, @-bottom@: length ** @padding@, with or without @-top@, @-left@, @-right@, @-bottom@: length ** @border@, with or without @-top@, @-left@, @-right@, @-bottom@; with or without @-width@, @-style@, @-color@ *** if @-width/-style/-color@ *and* @-top/-left/-right/-bottom@ is omitted: **** one value: @style@ **** two values: @width style@ **** three values: @width style color@. Applies to all sides of the element. ** @border-style@: @solid@, @dashed@, @dotted@, @none@, @double@ ** @border-color@: TeX color name (needs to be defined first with @\definecolor{<name>}{<color-space>}{<color-declaration>}@) or hex value @\#rrggbb@ ** @border-width@: length If there is no side with @-top/-left/-right/-bottom@ given, several values are possible: **** if there is one value it applies to all sides **** two values: @top/bottom@ and @left/right@ **** three values: @top@ and @left/right@ and @bottom@ **** four values: @top@ and @right@ and @bottom@ and @left@ ** @border-collapse@: @none@, @collapse@ ** @vertical-align@: @top@, @middle@, @bottom@ ** @background-color@: Hintergrundfarbe. TeX color name or hex value @\#rrggbb@ ** @color@: text color. TeX color name or hex value @\#rrggbb@ ** @font-size@: font size. @xx-small@, @x-small@, @small@, @normal@, @large@, @x-large@, @xx-large@ ** @font-weight@: font weight. @bold@, @normal@ ** @font-family@: font family. use values for generic font-families, e.g. @sans-serif@, @serif@, @monospace@ ** @font-style@: font style: @normal@, @italic@ ** @font-variant@: font variant: @normal@, @small-caps@ ** @text-align@: @right@, @center@, @left@, @justified@ ** @hyphen@: @none@ (no hyphenation), @auto@ (TeX-hyphenation) * @class=<name>@ corresponds to the class attribute in HTML. * the @\HTcol@-Element can yield a @width@ attribute with a given column width, e.g. <pre><code class="text">\col[width=20mm,style={text-align: center}] \col[width=0.2,style={text-align:justified,hyphen=auto}]</code></pre> The first column would have a fixed width of 20mm, the second a relative width of 20% of the width of the entire table. The first column is centered, the second is justified with activated hyphenation. Permissible values for column widths are: ** Length (number and measurement unit) for fixed with columns, ** Number <= 1 for relative width (0.5 is half of the table width) ** Number > 1 Anteile auf Gesamtsumme bezogen, e.g. three columns with @width=20@, @width=10@ and @width=30@ mean, that the first is one third of the total width (20/60), the secnd is a sixth (10/60) and the third is a half (30/60) of the total width. * @Htmltab@ can also have @width@, this would then correspond to the total width of the table. If this information is missing, the table is set in its _original width_, but at most the width of the type area (more precisely: @\linewidth@). * @\HTtd@ and @\HTth@ may contain @rowspan@ and @colspan@-attributes. They should include an integer. <pre><code class="text">\HTtd[rowspan=2,colspan=2,style={vertical-align: middle; text-align: center}]{<content>}</code></pre> This cell would be stretched over two columns *and* two rows, its contents would be centered vertically and horizontally. h3. Example: <pre><code class="text"> \begin{htmltab}[class=box] \begin{thead} \HTtr[style={text-align: center}]{% \HTtd[style={text-align: center; vertical-align: bottom}]{<Table head column 1>} \HTtd{<Table head column 2>} \HTtd{<Table head column 3>} } \end{thead} \begin{tfoot} \HTtr[colspan=3]{% \HTtd{<Table foot column 1–3>} } \end{tfoot} \begin{tbody} \HTtr{% \HTtd[rowspan=2]{<Table body row 1-2 column 1>} \HTtd{<Table body row 1 column 2>} \HTtd{<Table body row 1 column 3>} } \HTtr{% \HTtd{<Table body row 2 column 2>} \HTtd{<Table body row 2 column 3>} } \HTtr{% \HTtd{<Table body row 3 column 1>} \HTtd{<Table body row 3 column 2>} \HTtd{<Table body row 3 column 3>} } \end{tbody} \end{htmltab} </code></pre> h3. Overridable properties and @baretabular@ class * Certain CSS properties are not transferred to TeX by default, as these could possibly overwrite the publisher's specifications for table layouts: **@width@ on all elements that are not @<col>@, @<colgroup>@, or @<table>@ ** further properties can be configured in the publisher style (e.g. @background-color@ in @<thead>@, @padding-*@ an @td@, etc.) * the @baretabular@-Klasse is a special case: If @<table>@ has this class, *all* CSS properties are effective h2. Caption, Source and Floating htmltabs corresponds to the @tabular@ environment in default LaTeX. The markup of caption, number, source and legend corresponds to [[Figures#Single-column|tpFigure]]: <pre><code class="text"> \begin{tpTable}[<Floatpos>] \tpCaption{<Caption>} \tpSource{<Quelle>} \tpLegend{<Legende>} \tpNumber{<Zähler>} \begin{htmltab} … \end{htmltab} \end{tpTable} </code></pre> * @<Floatpos>@ represents the TeX float position (t,p,h,b; please see [[Figures#Single-column|tpFigure]]) ** if the optional argument is missing, the table is placed at the location in the content * %{color:#d20d20; font-weight:bold;} Please note% that the table can only be continued over pages, if it's not floating. This means if it is not wrapped in a @tpTable@ environment or if @tpTable@ exists but without optional argument. h2. Rotated Tables Gedrehte Tabellen h3. Markup Auszeichnung in Word In order for a table to be rotated by Damit eine Tabelle um 90 degrees, either the text direction of the first cell must be rotated Grad gedreht wird, muss entweder in Word or an empty paragraph with the die Textrichtung der ersten Zelle gedreht werden oder vor der Tabelle ein leerer Absatz mit dem Absatzformat @table_rotated@ paragraph style must appear in front of the table. stehen. h3. Markup Auszeichnung in LaTeX In Im TeX the table is marked with the attribute wird das ganze mit dem Attribut @orientation="landscape"@ in the optional argument e.g. im optionalen Argument der Gleitungebung gekennzeichnet, z.B. <pre><code class="text"> \begin{tpTable*}[orientation="landscape"] … \end{tpTable*} </code></pre> The specification of </code></pre>Die Angabe von float-pos is *always* overwritten with "@p@", wird dabei *immer* mit "p" überschrieben, demnach kann (und sollte) das Attribut bei gedrehten Tabellen entfallen. Dasselbe funktioniert genau so the attribute can (and should) be omitted for rotated tables. This works the same way with figures. auch mit Bildern. h2. Tabellen auf mehrere Seiten umbrechen Um Tabellen auf mehrere Seiten (mit sich wiederholendem Tabellenkopf zu umbrechen, muss der Tabelle ein leerer Absatz mit dem Absatzformat @table_pagewrap@ vorangestellt werden.