-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubfloat.sty
324 lines (302 loc) · 8.05 KB
/
subfloat.sty
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
% subfloat.sty: set sub-number within one float
% Iwakuma Tetsuo ([email protected]) 8/7/1992
% 10/10/1992
% header control added 4/19-22/1993
% header control added 8/7/1993
\@definecounter{subfloatnumber}
\def\@T@bLe{table}
\def\subfloatcap{-\alph{subfloatnumber}} % default
\newif\if@subfloatcaptionhead \@subfloatcaptionheadtrue
\def\NoSubfloatCaptionHead{\@subfloatcaptionheadfalse}
\newif\if@subfloatwithcaptionhead
\def\subcaption{\@ifstar{%
\@subfloatwithcaptionheadfalse\subc@ption}{%
\@subfloatwithcaptionheadtrue\subc@ption}}
\def\subc@ption{\@addtoreset{subfloatnumber}{\@captype}%
\ifx\@captype\@T@bLe\relax\else\addtocounter{\@captype}{1}\fi%
\def\the@subfloatnumber{\csname the\@captype\endcsname\subfloatcap}%
\stepcounter{subfloatnumber}%
\edef\@currentlabel{\csname the@subfloatnumber\endcsname}%
\@dblarg{\@subcaption\@captype}}
\long\def\@subcaption#1[#2]#3{\par\addcontentsline{\csname
ext@#1\endcsname}{#1}{\protect\numberline{\csname
the#1\endcsname\subfloatcap}{\ignorespaces #2}}\begingroup
\@parboxrestore
\small
\if@subfloatcaptionhead
\if@subfloatwithcaptionhead
\@makecaption{\csname fnum@#1\endcsname\subfloatcap}%
{\ignorespaces #3}\par
\else
\@makecaptionWOheading{\subfloatcap}{\ignorespaces #3}
\fi
\else\@makecaptionWOheading{}{\ignorespaces #3}\par\fi
\endgroup%
\ifx\@captype\@T@bLe\relax\else\addtocounter{\@captype}{-1}\fi}
\long\def\@makecaptionWOheading#1#2{%
\vskip 10\p@
\setbox\@tempboxa\hbox{#1 #2}%
\ifdim \wd\@tempboxa >\hsize
#1 #2\par
\else
\hbox to\hsize{\hfil\box\@tempboxa\hfil}%
\fi}
\endinput
% ----- example follows ----
\documentstyle[subfloat]{article}
\title{about {\tt subfloat.sty}}
\author{the author}
\date{Aug. 7, 1993}
\unitlength=1mm
\def\subpicture#1{\begin{picture}(50,7)(0,0)
\put(0,0){\framebox(50,7){#1}}\end{picture}}
\begin{document}
\maketitle
\begin{enumerate}
\item Subcaptions are specified by \verb+\subcaption{...}+ or
\verb+\subcaption*{...}+. While the former sets a heading
with for example `Figure' and figure number with subnumber,
the latter sets only the subnumber.
\item Always need to specify the main \verb+\caption{...}+.
\item Figure captions are always located BELOW the figures, while
table captions are ABOVE the tables including the main caption.
\item Subnumber system can be set by \verb+\subfloatcap+.
Its default is
\begin{verbatim}
\def\subfloatcap{-\alph{subfloatnumber}}
\end{verbatim}
\item \verb+\NoSubfloatCaptionHead+ will remove headings
for subcaptions such as `Figure' or `Table' plus figure numbers.
\end{enumerate}
In the case of figures, we need to set
\begin{verbatim}
\begin{figure}[h]
......
\subcaption{First Figure}
\label{fig:1}
......
\subcaption{Second Figure}
\label{fig:2}
\caption{Three Subfigures}
\label{fig:all}
\end{figure}
\end{verbatim}
Then typical outputs are shown in the {\bf Fig. \ref{fig:all}}.
\begin{figure}[t]
\begin{center}
\subpicture{First}
\subcaption{First Figure}
\label{fig:1}
\end{center}
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Second}
\subcaption{Second Figure}
\label{fig:2}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Third}
\subcaption{Third Figure}
\label{fig:3}
\end{center}
\end{minipage}
\caption{Three Subfigures}
\label{fig:all}
\end{figure}
On the other hand, {\bf Fig. \ref{fig:all2}} shows a modified
caption without figure number but with subnumber
using \verb+\subcaption*+, where the subnumber is set to
\begin{verbatim}
\def\subfloatcap{(\alph{subfloatnumber})}
\end{verbatim}
\begin{figure}[b]
\def\subfloatcap{(\alph{subfloatnumber})}
\begin{center}
\subpicture{Fourth}
\subcaption*{Fourth Figure}
\label{fig:4}
\end{center}
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Fifth}
\subcaption*{Fifth Figure}
\label{fig:5}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Sixth}
\subcaption*{Sixth Figure}
\label{fig:6}
\end{center}
\end{minipage}
\caption{The Next Three Subfigures}
\label{fig:all2}
\end{figure}
Of course, you can refer to these figures individually. For example,
\begin{verbatim}
{\bf Fig. \ref{fig:5}} shows that the results given in
{\bf Figs. \ref{fig:1}} and {\bf \ref{fig:2}} can be $\cdots$.
\end{verbatim}
will result in \vspace{2ex}
\fbox{\begin{minipage}{.75\textwidth}
{\bf Fig. \ref{fig:5}} shows that the results given in
{\bf Figs. \ref{fig:1}} and {\bf \ref{fig:2}} can be $\cdots$.
\end{minipage}}\vspace{2ex}
The default of the numbering system is shown above, and can be
changed by redefining \verb+\subfloatcap+ also shown above.
The examples of table environment in the next page use a new
definition as
\begin{verbatim}
\def\subfloatcap{-(\roman{subfloatnumber})}
\end{verbatim}
\def\subfloatcap{-(\roman{subfloatnumber})}
\begin{verbatim}
\begin{table}[h]
\caption{Three Subtables}
\label{tab:all}
......
\subcaption{First Table}
\label{tab:1}
......
\subcaption{Second Table}
\label{tab:2}
\end{table}
{\bf Table. \ref{tab:1}} shows that $\cdots$ because $\cdots$ as
shown in {\bf Tables \ref{tab:3}} and {\bf \ref{tab:6}}.
\end{verbatim}
\begin{table}[t]
\caption{Three Subtables}
\label{tab:all}
\begin{center}
\subpicture{First}
\subcaption{First Table}
\label{tab:1}
\end{center}
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Second}
\subcaption{Second Table}
\label{tab:2}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Third}
\subcaption{Third Table}
\label{tab:3}
\end{center}
\end{minipage}
\end{table}
\begin{table}[b]
\caption{The Next Three Subtables}
\label{tab:all2}
\begin{center}
\subpicture{Fourth}
\subcaption{Fourth Table}
\label{tab:4}
\end{center}
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Fifth}
\subcaption{Fifth Table}
\label{tab:5}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Sixth}
\subcaption{Sixth Table}
\label{tab:6}
\end{center}
\end{minipage}
\end{table}
{\bf Table. \ref{tab:1}} shows that $\cdots$ because $\cdots$ as
shown in {\bf Tables \ref{tab:3}} and {\bf \ref{tab:6}}.
If you do NOT need a header of subsections, insert a line of
\begin{verbatim}
\NoSubfloatCaptionHead
\end{verbatim}
at an appropriate position in that specific figure environment.
\begin{figure}[t]
\NoSubfloatCaptionHead
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{First}
\subcaption{First Figure}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Second}
\subcaption{Second Figure}
\end{center}
\end{minipage}
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Third}
\subcaption{Third Figure}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Fourth}
\subcaption{Fourth Figure}
\end{center}
\end{minipage}
\caption{Four Subfigures without headers}
\end{figure}
\begin{figure}[b]
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{First}
\subcaption{First Figure}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Second}
\subcaption{Second Figure}
\end{center}
\end{minipage}
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Third}
\subcaption{Third Figure}
\end{center}
\end{minipage}
~
\begin{minipage}[t]{.47\textwidth}
~
\begin{center}
\subpicture{Fourth}
\subcaption{Fourth Figure}
\end{center}
\end{minipage}
\caption{Four Subfigures with headers}
\end{figure}
\end{document}