summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/hvfloat/hvfloat.sty
blob: a3039d82038ac63dc1252da476e13d8d5cdcd869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{hvfloat}[2003/05/31 rotating of floating objects]
%%
%% IMPORTANT NOTICE:
%%
%% This is file `hvfloat.sty',
%%
%% Herbert Voss <voss@perce.de>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `hvfloat' offers rotating of captions and objects for floats
%%
\def\fileversion{1.1}
\def\filedate{2003/05/31}
\message{`hvfloat' v\fileversion, \filedate\space (Herbert Voss)}
%
%
\RequirePackage{graphicx}
\RequirePackage{keyval}
\RequirePackage{ifthen}
%
\newif\ifhv@fbox \hv@fboxfalse
\DeclareOption{fbox}{%
	\hv@fboxtrue%
	\setlength{\fboxsep}{1pt}%
}
\ProcessOptions\relax
%
\newlength{\hvObjectWidth}
\newlength{\hvCapWidth}
\newlength{\hvMaxCapWidth}
\newsavebox{\hvObjectBox}
\newsavebox{\hvCaptionBox}
\newsavebox{\hvOBox}
%
\newif\ifhv@useOBox
\newif\ifhv@nonFloat
\newif\ifhv@onlyText
\newif\ifhv@framedCaption
\newif\ifhv@framedObject
%
\def\hvSet@boolkey#1#2{%
  \csname hv@#2\ifx\relax#1\relax true\else#1\fi\endcsname}
%
\define@key{hvSet}{floatPos}[htbp]{	%		LaTeX's position parameters htbp
	\def\hvSet@floatPos{#1}%
}
\define@key{hvSet}{rotAngle}[0]{	%		rotates caption AND image together
	\def\hvSet@rotAngle{#1}%
}
\define@key{hvSet}{capWidth}[.8]{	%		object (w)idth)|object (h)eight|<scale of \columnwidth>
	\def\hvSet@capWidth{#1}%
}
\define@key{hvSet}{capAngle}[0]{	%		-360..+360
	\def\hvSet@capAngle{#1}%
}
\define@key{hvSet}{capPos}[b]{		%		(l)eft|(b)ottom|(t)op|(r)ight
	\def\hvSet@capPos{#1}%					it is relativ to the object
}
\define@key{hvSet}{capVPos}[c]{		%		(b)ottom|(c)enter|(t)op
	\def\hvSet@capVPos{#1}%					it is relativ to the object
}
\define@key{hvSet}{objectPos}[c]{	%		(l)eft|(c)enter|(r)ight
	\def\hvSet@objectPos{#1}%				it is relativ to the document
}
\define@key{hvSet}{objectAngle}[0]{	%		-360..+360
	\def\hvSet@objectAngle{#1}%
}
\define@key{hvSet}{floatCapSep}[5]{	%		a width with the unit pt
	\def\hvSet@floatCapSep{#1}%
}
\define@key{hvSet}{useOBox}[false]{	%		use of the hvOBox contents
	\lowercase{\hvSet@boolkey{#1}}{useOBox}%
}
\define@key{hvSet}{nonFloat}[false]{%		Do not use float environment
	\lowercase{\hvSet@boolkey{#1}}{nonFloat}%
}
\define@key{hvSet}{onlyText}[false]{%		Write the caption only as text
	\lowercase{\hvSet@boolkey{#1}}{onlyText}%
}
\define@key{hvSet}{framedCaption}[false]{%		boxed caption
	\lowercase{\hvSet@boolkey{#1}}{framedCaption}%
}
\define@key{hvSet}{framedObject}[false]{%		boxed object
	\lowercase{\hvSet@boolkey{#1}}{framedObject}%
}
%
\def\setDefaults{%
\setkeys{hvSet}{%
	floatPos=htbp, rotAngle=0, capWidth=0.8, capAngle=0,%
	capPos=b, capVPos=c, objectPos=c, objectAngle=0,%
	floatCapSep=5, useOBox=false, nonFloat=false,%
	onlyText=false}%
}
\setDefaults%
\ifhv@fbox
	\setkeys{hvSet}{framedCaption=true, framedObject=true}%
\fi
%
\def\hv@Top{t}
\def\hv@Bottom{b}
\def\hv@Right{r}
\def\hv@Left{l}
\def\hv@Center{c}
\def\hv@Width{w}
\def\hv@Height{h}
\def\hv@Zero{0}
%
\newlength{\hvAboveCaptionSkip}
\newlength{\hvBelowCaptionSkip}
\setlength{\belowcaptionskip}{\abovecaptionskip}% it is in latex.ltx = 0pt
\newcommand{\saveCaptionSkip}{%
	\setlength{\hvAboveCaptionSkip}{\abovecaptionskip}
	\setlength{\hvBelowCaptionSkip}{\belowcaptionskip}
	\setlength{\abovecaptionskip}{0pt}
	\setlength{\belowcaptionskip}{0pt}
}
\newcommand{\restoreCaptionSkip}{%
	\setlength{\abovecaptionskip}{\hvAboveCaptionSkip}
	\setlength{\belowcaptionskip}{\hvBelowCaptionSkip}
}
%
%
\newcommand{\figcaption}[2][]{\def\@captype{figure}%
	\ifthenelse{\equal{#1}{}}{\caption{#2}}{\caption[#1]{#2}}}
\newcommand{\tabcaption}[2][]{\def\@captype{table}%
	\ifthenelse{\equal{#1}{}}{\caption{#2}}{\caption[#1]{#2}}}
%
%
%
\def\hvFloat{\@ifnextchar[{\do@hvFloat}{\do@hvFloat[]}}
\def\do@hvFloat[#1]#2#3{%
	\setDefaults%
	\ifthenelse{\equal{#1}{}}{}{\setkeys{hvSet}{#1}}%
	\gdef\hv@floatType{#2}%
	\ifthenelse{\equal{#2}{}}{\setkeys{hvSet}{nonFloat=true}}{}%
	\gdef\hv@floatObject{#3}%
	\@ifnextchar[{\do@@hvFloat}{\do@@hvFloat[]}%
}
\def\do@@hvFloat[#1]#2#3{%
	\def\hv@shortCap{#1}
	\def\hv@longCap{#2}
	\def\hv@label{#3}
%\newcommand*{\hvFloat}[5][]{%
% [#1}: keyvalues
% #2: type  figure | table | ...
% #3: float contents
% [#4]: short caption
% #5: caption
% #6: label
%	\setDefaults%
%	\def\@tempa{#1}%
%	\ifx\@tempa\empty\else\setkeys{hvSet}{#1}\fi% set options, only when not empty
	\def\@tempa{90}%
	\ifx\hvSet@rotAngle\@tempa
		\setlength{\hvMaxCapWidth}{\textheight}
	\else
		\setlength{\hvMaxCapWidth}{\linewidth}
	\fi
%
% First we save the object in \hvObjectBox
%
	\ifx\hvSet@objectAngle\hv@Zero % rotate the object?
		\savebox{\hvObjectBox}{\ifhv@useOBox\usebox{\hvOBox}\else\hv@floatObject\fi}
	\else
		\savebox{\hvObjectBox}{%
			\rotatebox{\hvSet@objectAngle}{%
				\ifhv@useOBox\usebox{\hvOBox}\else\hv@floatObject\fi}}
	\fi
	\setlength{\hvObjectWidth}{\wd\hvObjectBox}
%
% Now we save the caption with its defined \hvCapWidth
%
	\ifx\hvSet@capWidth\hv@Width
		\setlength{\hvCapWidth}{\hvObjectWidth}
	\else
		\ifx\hvSet@capWidth\hv@Height
			\setlength{\hvCapWidth}{\ht\hvObjectBox}
		\else
			\setlength{\hvCapWidth}{\hvObjectWidth}
			\ifx\hvSet@capPos\hv@Left
				\addtolength{\hvMaxCapWidth}{-\hvObjectWidth}
			\fi
			\ifx\hvSet@capPos\hv@Right
				\addtolength{\hvMaxCapWidth}{-\hvObjectWidth}
			\fi
			\ifdim\hvSet@capWidth\columnwidth<\hvMaxCapWidth
				\setlength{\hvCapWidth}{\hvSet@capWidth\columnwidth}
			\else
				\setlength{\hvCapWidth}{\hvMaxCapWidth}
			\fi
		\fi
	\fi
%
% now we have the object and the caption with the right
% rotated angles saved in boxes
%
	\def\fps@figure{\hvSet@floatPos}
	\ifhv@nonFloat%
		\begingroup%	Start the nonfloat part
	\else%
		\begin{\hv@floatType}%		Start the floating environment
	\fi%
		\saveCaptionSkip% we put this space ourselve
		\ifx\hvSet@capAngle\hv@Width % need rotation?
			\sbox{\hvCaptionBox}{%
				\begin{minipage}[b]{\hvCapWidth}% minipage, to get hyphenation
					\ifhv@nonFloat%
						\ifhv@onlyText%
							#2%
						\else%
						    \ifthenelse{\equal{\hv@floatType}{figure}}{%
							\ifthenelse{\equal{#1}{}}{\figcaption{#2}}{\figcaption[#1]{#2}}%
						    }{%
							\ifthenelse{\equal{#1}{}}{\tabcaption{#2}}{\tabcaption[#1]{#2}}%
						    }%
						\fi%
					\else%
						\ifx\hv@shortCap\empty\caption{#2}\else\caption[#1]{#2}\fi%
					\fi%
					\label{#3}%
				\end{minipage}%
			}%
		\else%
			\sbox{\hvCaptionBox}{%
				\rotatebox{\hvSet@capAngle}{%
					\begin{minipage}[b]{\hvCapWidth}% minipage, to get hyphenation
						\ifhv@nonFloat%
							\ifhv@onlyText%
								#2%
							\else%
							    \ifthenelse{\equal{\hv@floatType}{figure}}{%
								\ifthenelse{\equal{#1}{}}{\figcaption{#2}}{\figcaption[#1]{#2}}%
							    }{%
								\ifthenelse{\equal{#1}{}}{\tabcaption{#2}}{\tabcaption[#1]{#2}}%
							    }%
							\fi%
						\else%
							\ifx\hv@shortCap\empty\caption{#2}\else\caption[#1]{#2}\fi%
						\fi%
						\label{#3}%
					\end{minipage}%
				}%
			}%
		\fi%
%%
		\restoreCaptionSkip% save old values
		\ifx\hvSet@objectPos\hv@Right%
			\raggedleft%
		\else%
			\ifx\hvSet@objectPos\hv@Center%
				\ifhv@nonFloat%
					\hspace*{\fill}%
				\else%
					\centering
				\fi%
			\fi%
		\fi%
%
% to rotate object and caption together, we save all in another box
% the caption comes first, if its on the left or the top
%
		\savebox{\@tempboxa}{%
			\ifx\hvSet@capPos\hv@Left  %  caption on left side
				\ifx\hvSet@capVPos\hv@Center%
					\ifhv@framedCaption%
						\fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}%
					\else
						\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}
					\fi%
		        	\hspace{\hvSet@floatCapSep pt}% capfloatsep
					\ifhv@framedObject%
						\fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}}
					\else
						\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}
					\fi%
				\else%
					\ifx\hvSet@capVPos\hv@Top % caption at top
						\ifhv@framedCaption%
							\fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}%
						\else
							\raisebox{-\height}{\usebox{\hvCaptionBox}}%
						\fi
						\hspace{\hvSet@floatCapSep pt}% capfloatsep
						\ifhv@framedObject%
							\fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}%
						\else
							\raisebox{-\height}{\usebox{\hvObjectBox}}%
						\fi%
					\else% caption on bottom
						\ifhv@framedCaption%
							\fbox{\usebox{\hvCaptionBox}}
						\else
							\usebox{\hvCaptionBox}
						\fi%
						\hspace{\hvSet@floatCapSep pt}%
						\ifhv@framedObject%
							\fbox{\usebox{\hvObjectBox}}
						\else
							\usebox{\hvObjectBox}
						\fi%
					\fi%
				\fi%
			\else
				\ifx\hvSet@capPos\hv@Top
					\ifdim\wd\hvCaptionBox>\wd\hvObjectBox
						\begin{minipage}{\wd\hvCaptionBox}
					\else
						\begin{minipage}{\wd\hvObjectBox}
					\fi
					\centering
					\ifhv@framedCaption%
						\fbox{\usebox{\hvCaptionBox}}\\[\hvBelowCaptionSkip]
					\else
						\usebox{\hvCaptionBox}\\[\hvBelowCaptionSkip]%
					\fi%
					\ifhv@framedObject%
						\fbox{\usebox{\hvObjectBox}}%
					\else
						\usebox{\hvObjectBox}%
					\fi%
					\end{minipage}
				\else
					\ifx\hvSet@capPos\hv@Bottom
						\ifdim\wd\hvCaptionBox>\wd\hvObjectBox
							\begin{minipage}{\wd\hvCaptionBox}
						\else
							\begin{minipage}{\wd\hvObjectBox}
						\fi
						\centering
						\ifhv@framedObject
							\fbox{\usebox{\hvObjectBox}}\\[\hvAboveCaptionSkip]
						\else
							\usebox{\hvObjectBox}\\[\hvAboveCaptionSkip]
						\fi%
						\ifhv@framedCaption
							\fbox{\usebox{\hvCaptionBox}}%
						\else
							\usebox{\hvCaptionBox}%
						\fi%
						\end{minipage}
					\else% the last option: put the caption on the right
						\ifx\hvSet@capVPos\hv@Center%
							\ifhv@framedObject
								\fbox{\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}}
							\else
								\parbox{\wd\hvObjectBox}{\usebox{\hvObjectBox}}
							\fi%
							\hspace{\hvSet@floatCapSep pt}%
							\ifhv@framedCaption
								\fbox{\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}}%
							\else
								\parbox{\wd\hvCaptionBox}{\usebox{\hvCaptionBox}}
							\fi%
						\else%
							\ifx\hvSet@capVPos\hv@Top
								\ifhv@framedObject
									\fbox{\raisebox{-\height}{\usebox{\hvObjectBox}}}%
								\else
									\raisebox{-\height}{\usebox{\hvObjectBox}}%
								\fi%
								\hspace{\hvSet@floatCapSep pt}%
								\ifhv@framedCaption
									\fbox{\raisebox{-\height}{\usebox{\hvCaptionBox}}}%
								\else
									\raisebox{-\height}{\usebox{\hvCaptionBox}}%
								\fi
							\else
								\ifhv@framedObject
									\fbox{\usebox{\hvObjectBox}}%
								\else
									\usebox{\hvObjectBox}%
								\fi
								\hspace{\hvSet@floatCapSep pt}%
								\ifhv@framedCaption
									\fbox{\usebox{\hvCaptionBox}}%
								\else
									\usebox{\hvCaptionBox}%
								\fi%
							\fi%
						\fi
					\fi
				\fi
			\fi
		}% End savebox Object and caption
%
% now we rotate the object and caption, if needed
%
		\ifx\hvSet@rotAngle\hv@Zero
			\usebox{\@tempboxa}
		\else
			\rotatebox{\hvSet@rotAngle}{\usebox{\@tempboxa}}
		\fi
	\ifhv@nonFloat
		\ifx\hvSet@objectPos\hv@Center
			\ifhv@nonFloat
				\hspace{\fill}
			\fi
		\fi
		\endgroup%	End the nonfloat part
	\else
		\end{\hv@floatType}%	End the floating environment
	\fi
	\ifhv@fbox % reset local settings
	    \setkeys{hvSet}{framedCaption=true, framedObject=true}
	\fi
}
%
\endinput