Projekt

Allgemein

Profil

Tables » Historie » Version 2

Martin Kraetke, 22.12.2021 17:58

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
h2. Gedrehte Tabellen
151
152
h3. Auszeichnung in Word
153
154
Damit eine Tabelle um 90 Grad gedreht wird, muss entweder in Word die Textrichtung der ersten Zelle gedreht werden oder vor der Tabelle ein leerer Absatz mit dem Absatzformat @table_rotated@ stehen.
155
156
h3. Auszeichnung in LaTeX
157
158
Im TeX wird das ganze mit dem Attribut @orientation="landscape"@ im optionalen Argument der Gleitungebung gekennzeichnet, z.B.
159
<pre><code class="text">
160
\begin{tpTable*}[orientation="landscape"]
161
162
\end{tpTable*}
163
</code></pre>Die Angabe von float-pos wird dabei *immer* mit "p" überschrieben, demnach kann (und sollte) das Attribut bei gedrehten Tabellen entfallen. Dasselbe funktioniert genau so auch mit Bildern.
164
165
h2. Tabellen auf mehrere Seiten umbrechen
166
167
Um Tabellen auf mehrere Seiten (mit sich wiederholendem Tabellenkopf zu umbrechen, muss der Tabelle ein leerer Absatz mit dem Absatzformat @table_pagewrap@ vorangestellt werden.