Debian Codegraph @

texmf-dist/doc/latex/floatrow/frsample03.tex

raw
1 %sample file
2 %table floats---different tests
3 \documentclass{book}
4
5 \usepackage{calc}
6 \usepackage{tabularx,array}
7
8 \usepackage{longtable}
9 \usepackage{floatpagestyle}
10
11 %load floatrow
12 \usepackage[font=small,footskip=.5\skip\footins,
13 capbesidesep=quad,floatrowsep=quad]{floatrow}
14
15 \floatsetup[table]{style=Plaintop,captionskip=5pt}
16 \floatsetup[longtable]{LTcapwidth=table,margins=centering}
17
18 %load caption
19 \usepackage[font=small,justification=centerlast]{caption}[2004/11/28]
20
21 %%%for all versions of caption 3.x?
22 \DeclareCaptionFormat{flushrightlabel}{\leavevmode\rightline{#1}#2#3\normalfont\par}
23 %%%for caption 3.d?
24 %\DeclareCaptionFormat*{flushrightlabel}{\rightline{#1}#3\par}
25
26 \captionsetup[table]%
27 {format=flushrightlabel,labelformat=continued,labelsep=newline,textfont=bf,labelfont=sl}
28 %%%for caption 3.d?
29 %\captionsetup[table]%
30 % {format=flushrightlabel,labelsep=none,textfont=bf,labelfont=sl}
31
32 %>>>
33 \DeclareCaptionLabelFormat{continued}{\bothIfFirst{#1}{ }#2\Continued}
34 \newcommand\Continued{}
35 %\DeclareCaptionLabelFormat{continued}{\bothIfFirst{#1}{ }#2. \emph{Continued}}
36 \def\ContinuedTable{\ContinuedFloat\def\Continued{. \emph{Continued}}\caption{}}
37 %\def\ContinuedTable{\ContinuedFloat\captionsetup[table]{labelformat=continued}\caption{}}
38 %<<<
39
40 \captionsetup[floatfoot]{format=default}
41 \captionsetup[longtable]{labelformat=default}
42
43
44 %load subfig
45 \newif\ifLoadSubfig
46 \IfFileExists{subfig.sty}{\usepackage[justification=centerlast]{subfig}
47 \captionsetup[subtable]{format=default,labelfont=bf,textfont=sl}
48
49 \AtBeginDocument{\floatsetup{subfloatrowsep=quad}}
50 \LoadSubfigtrue}{\LoadSubfigfalse}
51
52 \let\wideemptyfloatpage\emptyfloatpage
53
54 \newif\ifLoadRotating
55 \IfFileExists{rotating.sty}
56 {\usepackage[figuresright]{rotating}
57
58 \DeclareMarginSet{expand}%
59 {\setfloatmargins{\hfil}
60 {\hskip-\headsep\hskip-.7\headheight plus1fil}}
61 \floatsetup[rotfloat]{margins=expand}
62 \LoadRotatingtrue}{\LoadRotatingfalse}
63
64 \newcommand\TABULARX[1][]{\begin{tabularx}{\hsize}{|X|X|X|}
65 \hline
66 Text for first column of first row#1&
67 More text for second column of first row#1&
68 More text for third column of first row#1\\\hline
69 Text for first column of second row#1&
70 More text for second column of second row#1&
71 More text for third column of second row#1\\\hline
72 Text for first column of third row#1&
73 More text for second column of third row#1&
74 More text for third column of third row#1\\\hline
75 \end{tabularx}}
76
77 \newcommand\TABULARS[1][]{\begin{tabular*}
78 {\hsize}{@{\extracolsep{-.4\tabcolsep plus1fill}}|p{.29\hsize}|p{.29\hsize}|p{.29\hsize}|}
79 \hline
80 Text for first column of first row#1&
81 More text for second column of first row#1&
82 More text for third column of first row#1\\\hline
83 Text for first column of second row#1&
84 More text for second column of second row#1&
85 More text for third column of second row#1\\\hline
86 Text for first column of third row#1&
87 More text for second column of third row#1&
88 More text for third column of third row#1\\\hline
89 \end{tabular*}}
90
91 \newcommand\TABULARI{\begin{tabular}{|l|>{\phantom0}c|>{\phantom0}c|}
92 \hline
93 \raisebox{-1.5ex}{Column Head}
94 & \multicolumn{2}{c|}{Data} \\
95 \cline{2-3}
96 & \multicolumn{1}{c|}{I}
97 & \multicolumn{1}{c|}{II}
98 \\\hline
99 First row & 1 & 2 \\
100 Second row & 3 & 4 \\
101 Third row & 6 & 8 \\
102 Fourth row & \llap{1}0 & \llap{1}6 \\
103 \hline
104 \end{tabular}}
105
106 \newcommand\TABULARII{\begin{tabular}{|l|c|c|c|}
107 \hline
108 \raisebox{-1.5ex}{Column Head}
109 & \multicolumn{3}{c|}{Data} \\
110 \cline{2-4}
111 & I & II & III \\
112 \hline
113 First row & 1 & 2 & \phantom01 \\
114 Second row & 3 & 4 & \phantom06 \\
115 Third row & 6 & 8 & 28 \\
116 \hline
117 \end{tabular}}
118
119 \providecommand*{\Lopt}[1]{\textsf{#1}}
120 \providecommand*{\file}[1]{\texttt{#1}}
121 \providecommand*{\pkg}[1]{\texttt{#1}}
122 \providecommand*{\env}[1]{\texttt{#1}}
123 \providecommand*{\com}[1]{\texttt{\char`\\#1}}
124 \providecommand*{\meta}[1]{$\langle$\textit{#1}$\rangle$}
125
126 \hfuzz3pt
127 \hbadness7000
128
129 \def\text{And more text and some more text and a bit more text and
130 a little more text and a little peace of text to fill space}
131
132 \def\Text{{\mdseries \text. \text. \text. \text. }}
133
134 \begin{document}
135
136 \chapter{Table Layout}
137
138 \begin{sl}
139 This example shows floats in one-column document.
140
141 \emph{Common float settings.}\\
142 Font for float contents \verb|\small|; skips before foot material half reduced;
143 footnote rule has maximum width${{}\approx27}$\,mm; separation between
144 beside caption and object equals to 1\,em; separation between beside float
145 boxes also equals to 1\,em.
146 \begin{verbatim}
147 \usepackage[font=small,footskip=.5\skip\footins,
148 captionskip=5pt,capbesidesep=quad,floatrowsep=quad]{floatrow}
149 \end{verbatim}
150
151 \emph{Common caption settings.}\\
152 For caption text used \verb|\small| font;
153 justification \texttt{centerlast} (last line centered).
154 \begin{verbatim}
155 \usepackage[font=small,justification=centerlast]{caption}
156 \end{verbatim}
157
158 \emph{Common subcaption settings.}\\
159 Justification centerlast (last line centered).
160 \begin{verbatim}
161 \usepackage[justification=centerlast]{subfig}
162 \end{verbatim}
163
164 \emph{Special settings for float types.}
165
166 \emph{Table.}\\
167 For tables is used \texttt{Plaintop} style (captions aligned by top line);
168 skip between caption and object half reduced.
169 \begin{verbatim}
170 \floatsetup[table]{style=Plaintop,captionskip=5pt}
171 \end{verbatim}
172
173 \emph{Special caption settings for float types.}
174
175 \emph{Table.}\\
176 For tables was created special format with separated label flushed to the right;
177 font of label slanted, font of caption text bold.
178
179 To restore normal behavior for \verb|\floatfoot| macro, here goes \verb|\captionsetup|
180 for \texttt{floatfoot} style.
181 \begin{verbatim}
182 \DeclareCaptionFormat{flushrightlabel}{\leavevmode
183 \rightline{#1}#2#3\par}
184
185 \captionsetup[table]%
186 {format=flushrightlabel,labelsep=newline,
187 textfont=bf,labelfont=sl}
188
189 \captionsetup[floatfoot]{format=default}
190 \end{verbatim}
191 With caption's version 3d you may set table format by this way:
192 \begin{verbatim}
193 \DeclareCaptionFormat*{flushrightlabel}{\rightline{#1}#3\par}
194
195 \captionsetup[table]%
196 {format=flushrightlabel,labelsep=none,textfont=bf,labelfont=sl}
197 \end{verbatim}
198 You may see, that there are absent settings for \verb|\floatfoot|.
199 (Unfortunately, if your table has only label, and no any text, the unwanted
200 space appears instead of caption title.)
201
202 For continued table (like table~\ref{rot:tab:cont} on the page~\pageref{rot:tab:cont})
203 was created new label format and defined command \verb|\ContinuedTable|, which includes
204 special \texttt{continued} format and \verb|\ContinuedFloat| command.
205 \begin{verbatim}
206 \DeclareCaptionLabelFormat{continued}{\bothIfFirst{#1}{ }#2.
207 \emph{Continued}}
208
209 \def\ContinuedTable{\ContinuedFloat
210 \captionsetup[table]{labelformat=continued}}
211 \end{verbatim}
212
213 \emph{Special settings for special float layout.}
214
215 \emph{Rotated.}\\
216 For rotated floats beside caption placed to right side of object;
217 right side expanded to the top of running head. To delete running head from pages
218 with rotated float was used \verb|\emptyfloatpage| macro\footnote{In current example the
219 \protect\com{wideemptyfloatpage} command is the synonym.} and
220 loaded \pkg{floatpagestyle} package.
221 \begin{verbatim}
222 \DeclareMarginSet{expand}%
223 {\setfloatmargins{\hfil}
224 {\hskip-\headsep\hskip-.7\headheight plus1fil}}
225 \floatsetup[rotfloat]{sidecappos=right,floatmargins=expand}
226 \end{verbatim}
227
228 \end{sl}
229
230 \clearpage
231 \bfseries\boldmath
232 Example of plain \env{table} environment (table~\ref{float:plain:table}),
233
234 \begin{table}
235 \caption{Plain table environment with \env{tabularx}. \text}\label{float:plain:table}
236 \TABULARX
237 \end{table}
238
239 \Text
240
241 \Text
242
243 \clearpage
244 Example of plain \env{table} environment (table~\ref{float:w:plain:table})
245 with predefined width.
246 Before \env{table} environment was written:
247 \begin{verbatim}
248 \thisfloatsetup{floatwidth=.85\hsize}
249 \end{verbatim}
250
251 \thisfloatsetup{floatwidth=.85\hsize}
252 \begin{table}
253 \caption{Plain table environment (\env{tabularx}) with predefined width. \text}\label{float:w:plain:table}
254 \TABULARX
255 \end{table}
256
257
258 \Text
259
260 \clearpage
261 Example of table placed in \verb|\ttabbox| (\verb|\floatbox| stuff);
262 the width of float box equals to the width of table
263 (see table~\ref{floatbox:FB:tab}).
264
265 \begin{table}
266 \floatbox{table}[\FBwidth]
267 {\caption{Float box table (\protect\com{ttabbox})
268 width of table}\label{floatbox:FB:tab}}
269 {\tabcolsep2\tabcolsep\TABULARI\floatfoot{Text of floatfoot. \text}}
270 \end{table}
271
272 \Text
273
274 \ifLoadSubfig
275
276 \clearpage
277 The example of subtables (table~\ref{floatbox:wide:subtab}) with two
278 subtables~\subref{subtab:A} and~\subref{subtab:B}.
279
280 Here for sub tables was used the \env{subfloatrow} environment (this environment
281 allows usage (and definition) of common horizontal skip between subfloats).
282 \begin{verbatim}
283 \begin{table*}\extrarowheight1pt
284 \floatbox[\captop]{table}[\FBwidth]
285 {\caption{...}
286 {\begin{subfloatrow}
287 \subfloat[...]{...}
288
289 \subfloat[...]{...}%
290 \end{subfloatrow}}
291 \end{table*}%
292 \end{verbatim}
293
294 \begin{table*}\extrarowheight1pt
295 \floatbox[\captop]{table}[\FBwidth]
296 {\caption{Table with two \protect\com{subfloats}
297 (from \pkg{subfig} package)}\label{floatbox:wide:subtab}}
298 {\begin{subfloatrow}
299 \subfloat[First table\label{subtab:A}]
300 {\TABULARI}%
301
302 \subfloat[Second table with long long long caption\label{subtab:B}]
303 {\TABULARII}%
304 \end{subfloatrow}}
305 \end{table*}%
306
307 \Text
308
309 \fi
310
311 \clearpage
312 The example of table row (tables~\ref{tab:row:tabI}--\ref{tab:row:tabII}).
313
314 \begin{table*}
315 \begin{floatrow}
316 \extrarowheight1pt
317 \ttabbox
318 {\caption[Beside table~I long header]%
319 {Beside table~I with long long long top aligned header}\label{tab:row:tabI}}
320 {\TABULARI}
321 %
322 \ttabbox
323 {\caption{Beside table~II short header}\label{tab:row:tabII}}
324 {\TABULARII}
325 \end{floatrow}
326 \end{table*}
327
328 \Text
329
330 \clearpage
331 Example of two rows: first---of beside tables in \env{tabularx} environments;
332 second---of beside tables in \env{tabular*} environments. Both rows use first column width${}=.85$\verb|\hsize|,
333 and second column${}=1.15$\verb|\hsize|.
334 (see tables~\ref{rot:tabx:tab1}--\ref{rot:tabx:tab2}).
335
336 \begin{table}[!t]
337 \begin{floatrow}\tabcolsep.5\tabcolsep
338 \ttabbox[.85\hsize]{\begin{tabularx}{\hsize}{|X|X|}
339 \hline
340 A text for first column of first row&
341 More text for second column of first row\\\hline
342 A text for first column of second row&
343 More text for second column of second row\\\hline
344 A text for first column of third row&
345 More text for second column of third row\\\hline
346 \end{tabularx}}{\caption{The \env{tabularx} environment with width \texttt{.85}\protect\com{hsize}}\label{rot:tabx:tab1}}
347 \ttabbox[1.15\hsize]{\begin{tabularx}{\hsize}{|X|X|}
348 \hline
349 Text for first column of first row&
350 More text for second column of first row\\\hline
351 Text for first column of second row&
352 More text for second column of second row\\\hline
353 Text for first column of third row&
354 More text for second column of third row\\\hline
355 \end{tabularx}}{\caption{The \env{tabularx} (from \pkg{tools} bundle) environment with width \texttt{1.15}\protect\com{hsize}}}
356 \end{floatrow}
357 \vskip\floatsep
358
359 \begin{floatrow}\tabcolsep.75\tabcolsep
360 \ttabbox[.85\hsize]{{\begin{tabular*}{\hsize}{@{\extracolsep{-.4\tabcolsep plus1fill}}
361 |p{.44\hsize}|p{.44\hsize}|}
362 \hline
363 A text for first column of first row&
364 More text for second column of first row\\\hline
365 A text for first column of second row&
366 More text for second column of second row\\\hline
367 A text for first column of third row &
368 More text for second column of third row\\\hline
369 \end{tabular*}}}{\caption{The \env{tabular*} environment with width \texttt{.85}\protect\com{hsize}}}
370 \ttabbox[1.15\hsize]{{\begin{tabular*}{\hsize}{@{\extracolsep{-.4\tabcolsep plus1fill}}|p{.45\hsize}|p{.45\hsize}|}
371 \hline
372 Text for first column of first row&
373 More text for second column of first row\\\hline
374 Text for first column of second row&
375 More text for second column of second row\\\hline
376 Text for first column of third row &
377 More text for second column of third row\\\hline
378 \end{tabular*}}}{\caption{The starred \LaTeX's \env{tabular*} environment with width \texttt{1.15}\protect\com{hsize}}\label{rot:tabx:tab2}}
379 \end{floatrow}
380 \end{table}
381
382 \Text
383
384 \clearpage
385 Example of continued rotated plain table on facing pages
386 (see table~\ref{rot:tab} on pages~\pageref{rot:tab}--\pageref{rot:tab:cont}).
387
388 \ifodd\value{page}\else
389 \Text \Text
390
391 \Text \Text
392
393 \ifodd\value{page}\else
394 \Text \Text
395 \Text \Text
396
397 \Text \Text
398
399 \fi
400
401 \fi
402
403 \newdimen\rottextwidth\rottextwidth\textwidth
404
405 \begin{sidewaystable}
406 \buildFBBOX{\vbox to\rottextwidth\bgroup\vss}{\egroup}
407 \wideemptyfloatpage
408 \caption{Plain table inside
409 \protect\env{sidewaystable} environment,
410 full text width. \text}\label{rot:tab}
411
412 \TABULARX[ \text. \text. ]
413 \end{sidewaystable}
414 %
415 \begin{sidewaystable}
416 \buildFBBOX{\vbox to\rottextwidth\bgroup}{\vss\egroup}
417 \emptyfloatpage\ContinuedTable
418 \label{rot:tab:cont}
419
420 \TABULARX[ \text.]
421 \end{sidewaystable}
422
423 \Text
424
425 \Text
426
427 \Text
428
429 \Text
430
431 \clearpage
432 Example of two beside tables in wide rotated table environment (\env{sidewaystable*})
433 (see tables~\hbox{\ref{rot:side:tab1}--\ref{rot:side:tab2}}
434 on page~\pageref{rot:side:tab1}).
435
436 \begin{sidewaystable*}\wideemptyfloatpage
437 \begin{floatrow}
438 \ttabbox[\hsize]
439 {{\TABULARS[. \text]\floatfoot{If you use inside \protect\com{floatbox} stuff
440 \texttt{tabularx} or \texttt{tabular*} environments with \protect\com{hsize}
441 command inside \meta{width} argument, you must repeat the \protect\com{hsize} argument
442 in \meta{width} argument of \protect\com{floatbox} macro.}}}
443 {\caption{}\label{rot:side:tab1}}
444 \ttabbox[\hsize]
445 {{\TABULARS[. \text]\floatfoot{If you want to set width of \texttt{tabularx} or \texttt{tabular*} environments
446 like \texttt{.8}\protect\com{hsize} (or \texttt{1.2}\protect\com{hsize}) and they placed inside any
447 \protect\com{floatbox} macro, load \texttt{.8}\protect\com{hsize} in \meta{width} argument of
448 \protect\com{floatbox} macro, and in \meta{width} argument of \texttt{tabularx} or \texttt{tabular*}
449 load only \protect\com{hsize} macro.}}}
450 {\caption{}\label{rot:side:tab2}}
451 \end{floatrow}
452
453 \end{sidewaystable*}
454
455 \Text
456
457 \Text
458
459 \clearpage
460 Example of two rows of beside tables in wide rotated table
461 (see tables~\ref{rot:tworow:tab1}--\ref{rot:tworow:tab2} on page~\pageref{rot:tworow:tab2}).
462 There were used \env{tabularx} environment in first row and
463 \env{tabular*}---in the second.
464
465 \begin{sidewaystable*}\wideemptyfloatpage
466 \begin{floatrow}
467 \ttabbox[\hsize]
468 {{\TABULARX}}{\caption{}\label{rot:tworow:tab1}}
469 \ttabbox[\hsize]
470 {{\TABULARX}}{\caption{}}
471 \end{floatrow}
472 \vskip\floatsep
473
474 \begin{floatrow}
475 \ttabbox[\hsize]{{\TABULARS}}{\caption{}}
476 \ttabbox[\hsize]{{\TABULARS}}{\caption{}\label{rot:tworow:tab2}}
477 \end{floatrow}
478
479 \end{sidewaystable*}
480
481 \Text
482 \Text
483
484
485 \end{document}