9.02.2008

并列的子图形

27.3 并列的子图形

在某些情况下,有时会希望将并列的图形组成一组,而其中的每一幅图 都保持其独立性。 paisubfigure 宏包的 \subfigure 命令将这一 组做为一幅图形,其中的每一幅图做为子图形。例如:
\begin{figure}
\centering
\subfigure[Small Box with a Long Caption]{
\label{fig:subfig:a} %% label for first subfigure
\includegraphics[width=1.0in]{graphic.eps}}
\hspace{1in}
\subfigure[Big Box]{
\label{fig:subfig:b} %% label for second subfigure
\includegraphics[width=1.5in]{graphic.eps}}
\caption{Two Subfigures}
\label{fig:subfig} %% label for entire figure
\end{figure}
生成图 27.9。这里使用 LATEX 的引用命令 \ref{fig:subfig:a} 会得到 27.9(a)\ref{fig:subfig:b} 得到 27.9(b)\ref{fig:subfig} 得到 27.9
\includegraphics[width=1in]{graphic.eps}
像其它的并列图形一样,子图也可以在小页环境中使用。而且在一些情况下, 这样做还能更方便的得到理想的图形间距。例如:
\begin{figure}
\subfigure[Small Box with a Long Caption]{
\label{fig:mini:subfig:a} %% label for first subfigure
\begin{minipage}[b]{0.5\textwidth}
\centering
\includegraphics[width=1in]{graphic.eps}
\end{minipage}}%
\subfigure[Big Box]{
\label{fig:mini:subfig:b} %% label for second subfigure
\begin{minipage}[b]{0.5\textwidth}
\centering
\includegraphics[width=1.5in]{graphic.eps}
\end{minipage}}
\caption{Minipages Inside Subfigures}
\label{fig:mini:subfig} %% label for entire figure
\end{figure}
得到图 27.10,其中包括两个子图 27.10(a)27.10(b)

\includegraphics[width=1in]{graphic.eps}
27.10 中的子图标题比图 27.9 中的要宽一些。 这是因为子图标题的宽度和子图的宽度相同,图 27.9 中的子图 只包含图形,而图 27.10 中的子图包含了宽度为 0.5\textwidth 的小页。 子图的标记有两种形式:
  1. 一种是出现在子图的下面作为标题的一部分。这通过命令 \@thesubfigure 来生成。
  2. 另一种是在使用 \ref 命令的时候出现。这通过将命令 \p@subfigure 的输出处理后传递给 \thesubfigure 命令来生成。
上面的这些命令使用 subfigure 计数器和 \thefigure 命令。 子图的标记的格式由下面的命令来控制。
  • 命令 \thefigure 印出当前图形的编号。
  • 计数器 subfigure 记录子图的编号,命令 \alph{subfigure} 将计数器 subfigure 的值用小写字母印出,而 命令 \roman{subfigure} 则是用小写罗马数字印出(有关印出 计数器值的命令可参见文献 [1, 第 98 页] 和 [3, 第 446 页]。)。
  • 命令 \thesubfigure 缺省使用小写字母,如 (a),(b) 等。
  • 命令 \@thesubfigure 缺省为 \thesubfigure\space,即在 标题标记和文本之间加上一个空白。
  • 命令 \p@subfigure 缺省为 \thefigure
如果改变子图标题的标记,字体等的缺省值,可参见文献 [10]。下面 给出几个简单的例子:
  • 若想让子图标题标记使用小写罗马数字如 (i), (ii)等, \ref 命令的结果 如 12i, 12ii 等,可使用下面的命令(最好放在导言区中)
          \renewcommand{\thesubfigure}{\roman{subfigure}}
    \makeatletter
    \renewcommand{\@thesubfigure}{(\thesubfigure)\space}
    \renewcommand{\p@subfigure}{\thefigure}
    \makeatother
  • 若想让子图标题标记使用阿拉伯数字如 12.1:, 12.2: 等, \ref 命令的结果 如 12.1, 12.2 等,可使用下面的命令

    \renewcommand{\thesubfigure}%
    {\thefigure.\arabic{subfigure}}
    \makeatletter
    \renewcommand{\@thesubfigure}{\thesubfigure:\space}
    \renewcommand{\p@subfigure}{}
    \makeatother
缺省情况下,用 \listoffigures 命令生成的图形目录中只包括图形, 而不包括子图。要想在图形目录中包括子图,要在 \listoffigures 命令前加上 \setcounter{lofdepth}{2}。 需要说明的是,由于 LATEX 的变化,导致目前版本(3/95) 的 subfigure 宏包在图形目录的子图输入项开始部分都加上 ``numberline1''。将下面的代码加到导言区中就可以解决这一问题。
\makeatletter
\renewcommand{\@subcaption}[2]{%
\begingroup
\let\label\@gobble
\def\protect{\string\string\string}%
\xdef\@subfigcaptionlist{%
\@subfigcaptionlist,%
{\numberline {\@currentlabel}%
\noexpand{\ignorespaces #2}}}%
\endgroup
\@nameuse{@make#1caption}{\@nameuse{@the#1}}{#2}}
\makeatother

没有评论: