Projekt

Allgemein

Profil

Tables » Historie » Version 5

Martin Kraetke, 22.12.2021 18:03

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