Projekt

Allgemein

Profil

Tables » Historie » Version 3

Martin Kraetke, 22.12.2021 18:02

1 1 Martin Kraetke
h1. Tables
2
3
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.
4
5
h2. Include htmltabs
6
7
Add this line to the preamble
8
9
<pre>
10
\usepackage{htmltabs}
11
</pre>
12
13
h2. Table Markup
14
15
h3. Mapping XHTML -> LaTeX
16
17
The htmltabs markup reflects the structure of a HTML table.
18
19
20
|_. XML |_. TeX |_. Description |
21
|<table>…</table>|\begin{htmltab}[…] … \end{htmltab}| |
22
|<col />|\HTcol[…]| vor thead |
23
|<colgroup>…</colgroup>|\HTcolgroup[…]{…}| before thead |
24
|<thead>…</thead>|\begin{thead}[…] … \end{thead}| after tbody |
25
|<tfoot>…</tfoot>|\begin{tfoot}[…] … \end{tfoot}| after tbody, before thead |
26
|<tbody>…</tbody>|\begin{tbody}[…] … \end{tbody}| |
27
|<tr>…</tr>|\HTtr[…]{…}| |
28
|<td>…</td>|\HTtd[…]{…}| |
29
|<th>…</th>|\HTth[…]{…}| |
30
31
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.
32
33
h3. Attributes and CSS Properties
34
35
The following "attributes" can be included in the optional argument (if empty, omit) of all "elements":
36
* @style={}@ contains CSS property-value pairs, syntax within the curly braces is as in XML, e.g.
37
38
<pre><code class="text">\HTtd[style={<CSS-Eigenschaft-1>:<CSS-Wert-1>; <CSS-Eigenschaft-2>: <CSS-Wert-2>; … }]{<Inhalt>}</code></pre>
39
40
The CSS properties in the HTML can be transferred directly to TeX. The same applies to the environments: 
41
42
<pre><code class="text">\begin{htmltab}[style={<CSS-Eigenschaft-1>:<CSS-Wert-1>; <CSS-Eigenschaft-2>: <CSS-Wert-2>; … }]
43
  …</code></pre>
44
45
Currently implemented CSS properties:
46
** @margin@, with or without @-top@, @-left@, @-right@, @-bottom@: length
47
** @padding@, with or without @-top@, @-left@, @-right@, @-bottom@: length
48
** @border@, with or without @-top@, @-left@, @-right@, @-bottom@; with or without @-width@, @-style@, @-color@
49
*** if @-width/-style/-color@ *and* @-top/-left/-right/-bottom@ is omitted:
50
**** one value: @style@
51
**** two values: @width style@
52
**** three values: @width style color@. Applies to all sides of the element.
53
** @border-style@: @solid@, @dashed@, @dotted@, @none@, @double@
54
** @border-color@: TeX color name (needs to be defined first with @\definecolor{<name>}{<color-space>}{<color-declaration>}@) or hex value @\#rrggbb@
55
** @border-width@: length
56
If there is no side with @-top/-left/-right/-bottom@ given, several values are possible:
57
**** if there is one value it applies to all sides
58
**** two values: @top/bottom@ and @left/right@
59
**** three values: @top@ and @left/right@ and @bottom@
60
**** four values: @top@ and @right@ and @bottom@ and @left@
61
** @border-collapse@: @none@, @collapse@
62
** @vertical-align@: @top@, @middle@, @bottom@
63
** @background-color@: Hintergrundfarbe. TeX color name or hex value @\#rrggbb@
64
** @color@: text color. TeX color name or hex value @\#rrggbb@
65
** @font-size@: font size. @xx-small@, @x-small@, @small@, @normal@, @large@, @x-large@, @xx-large@
66
** @font-weight@: font weight. @bold@, @normal@
67
** @font-family@: font family. use values for generic font-families, e.g. @sans-serif@, @serif@, @monospace@
68
** @font-style@: font style: @normal@, @italic@
69
** @font-variant@: font variant: @normal@, @small-caps@
70
** @text-align@: @right@, @center@, @left@, @justified@
71
** @hyphen@: @none@ (no hyphenation), @auto@ (TeX-hyphenation)
72
* @class=<name>@ corresponds to the class attribute in HTML.
73
* the @\HTcol@-Element can yield  a @width@ attribute with a given column width, e.g.
74
  <pre><code class="text">\col[width=20mm,style={text-align: center}]
75
\col[width=0.2,style={text-align:justified,hyphen=auto}]</code></pre>
76
  The first column would have a fixed width of 20mm, the second a relative width of 20% of the width of the entire table.
77
  The first column is centered, the second is justified with activated hyphenation. Permissible values for column widths are:
78
** Length (number and measurement unit) for fixed with columns, 
79
** Number <= 1  for relative width (0.5 is half of the table width)
80
** 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.
81
* @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@). 
82
* @\HTtd@ and @\HTth@ may contain @rowspan@ and @colspan@-attributes. They should include an integer.
83
<pre><code class="text">\HTtd[rowspan=2,colspan=2,style={vertical-align: middle; text-align: center}]{<content>}</code></pre>
84
This cell would be stretched over two columns *and* two rows, its contents would be centered vertically and horizontally. 
85
86
h3. Example:
87
88
<pre><code class="text">
89
\begin{htmltab}[class=box]
90
  \begin{thead}
91
    \HTtr[style={text-align: center}]{%
92
       \HTtd[style={text-align: center; vertical-align: bottom}]{<Table head column 1>}
93
       \HTtd{<Table head column 2>}
94
       \HTtd{<Table head column 3>}
95
    }
96
  \end{thead}
97
  \begin{tfoot}
98
    \HTtr[colspan=3]{%
99
       \HTtd{<Table foot column 1–3>}
100
    }
101
  \end{tfoot}
102
  \begin{tbody}
103
    \HTtr{%
104
       \HTtd[rowspan=2]{<Table body row  1-2 column 1>}
105
       \HTtd{<Table body row   1 column 2>}
106
       \HTtd{<Table body row  1 column 3>}
107
    }
108
    \HTtr{%
109
       \HTtd{<Table body row  2 column 2>}
110
       \HTtd{<Table body row  2 column 3>}
111
    }
112
    \HTtr{%
113
       \HTtd{<Table body row  3 column 1>}
114
       \HTtd{<Table body row  3 column 2>}
115
       \HTtd{<Table body row  3 column 3>}
116
    }
117
  \end{tbody}
118
\end{htmltab}
119
</code></pre>
120
121
h3. Overridable properties and @baretabular@ class
122
123
* Certain CSS properties are not transferred to TeX by default, as these could possibly overwrite the publisher's specifications for table layouts: 
124
**@width@ on all elements that are not @<col>@, @<colgroup>@, or @<table>@ 
125
** further properties can be configured in the publisher style (e.g. @background-color@ in @<thead>@, @padding-*@ an @td@, etc.)
126
* the @baretabular@-Klasse is a special case: If @<table>@ has this class, *all* CSS properties are effective
127
128
h2. Caption, Source and Floating
129
130 2 Martin Kraetke
htmltabs corresponds to the @tabular@ environment in default LaTeX.
131 1 Martin Kraetke
132 2 Martin Kraetke
The markup of caption, number, source and legend corresponds to [[Figures#Single-column|tpFigure]]:
133
134 1 Martin Kraetke
<pre><code class="text">
135
\begin{tpTable}[<Floatpos>]
136
  \tpCaption{<Caption>}
137
  \tpSource{<Quelle>}
138
  \tpLegend{<Legende>}
139
  \tpNumber{<Zähler>}
140
  \begin{htmltab}
141
142
  \end{htmltab}
143
\end{tpTable}
144
</code></pre>
145
146 2 Martin Kraetke
* @<Floatpos>@ represents the TeX float position (t,p,h,b; please see [[Figures#Single-column|tpFigure]])
147
** if the optional argument is missing, the table is placed at the location in the content
148
* %{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.
149 1 Martin Kraetke
150 3 Martin Kraetke
h2. Rotated Tables
151 1 Martin Kraetke
152 3 Martin Kraetke
h3. Markup in Word
153 1 Martin Kraetke
154 3 Martin Kraetke
In order for a table to be rotated by 90 degrees, either the text direction of the first cell must be rotated in Word or an empty paragraph with the @table_rotated@ paragraph style must appear in front of the table. 
155 1 Martin Kraetke
156 3 Martin Kraetke
h3. Markup in LaTeX
157 1 Martin Kraetke
158 3 Martin Kraetke
In TeX the table is marked with the attribute @orientation="landscape"@ in the optional argument e.g. 
159
160 1 Martin Kraetke
<pre><code class="text">
161
\begin{tpTable*}[orientation="landscape"]
162
163
\end{tpTable*}
164 3 Martin Kraetke
</code></pre>
165
166
The specification of float-pos is *always* overwritten with "@p@", so the attribute can (and should) be omitted for rotated tables. This works the same way with figures.
167 1 Martin Kraetke
168
h2. Tabellen auf mehrere Seiten umbrechen
169
170
Um Tabellen auf mehrere Seiten (mit sich wiederholendem Tabellenkopf zu umbrechen, muss der Tabelle ein leerer Absatz mit dem Absatzformat @table_pagewrap@ vorangestellt werden.