Subfloats[edit]
A useful extension is the subcaption package which uses subfloats within a single float. The subfigure and subfig packages are deprecated however they are useful alternatives when used in-conjunction with latex templates (i.e templates for journals from Springer and IOP, IEEETran and ACM SIG) that are not compatible with subcaption(建议不要使用subfigure和subfig package.注意不是subfigure命令). These packages give the author the ability to have subfigures within figures, or subtables within table floats. Subfloats have their own caption, and an optional global caption. An example will best illustrate the usage of the subcaption package:
\end{figure} |
You will notice that the figure environment is set up as usual. You may also use a table environment for subtables. For each subfloat, you need to use:
|
If you intend to cross-reference any of the subfloats, see where the label is inserted; \caption
outside the subfigure-environment will provide the global caption.
subcaption will arrange the figures or tables side-by-side providing they can fit, otherwise, it will automatically shift subfloats below. This effect can be added manually, by putting the newline command (\\
) before the figure you wish to move to a newline.
Horizontal spaces between figures are controlled by one of several commands, which are placed in between \begin{subfigure}
and \end{subfigure}
:
- A non-breaking space (specified by ~ as in the example above) can be used to insert a space in between the subfigs.
- Math spaces:
\qquad
,\quad
,\;
, and\,
- Generic space:
\hspace{''length''}
- Automatically expanding/contracting space:
\hfill
\begin{figure}[!h]
\centering\begin{subfigure}{.24\textwidth}
\includegraphics[width=\textwidth]{fig/ho}
\caption{Loads.}
\end{subfigure}
\begin{subfigure}{.24\textwidth}
\includegraphics[width=\textwidth]{fig/he}
\caption{Volume Opt.}
\end{subfigure}
\caption{O.}
\label{figure:op}
\end{figure}