【发布时间】:2010-01-08 03:38:46
【问题描述】:
我正在使用包 subfigure 和 float 创建我想要创建的图形和表格,并且我正在尝试创建自己的环境 graph 带有自己的计数器和标题 (solved there,谢谢给dmckee)。现在我想创建\subgraph 命令,它的作用与\subfigure 命令完全相同。
我尝试使用适当的计数器创建自己的命令(Assisted here,感谢 Alexey)。但是使用\ref 命令会出现问题。对\subfigure 的引用返回2.1(a),但对\subgraph 的引用返回1。
当我试图找出如何解决这个问题时,我阅读了subfig 手册,在那里我找到了带有示例的\newsubfloat 命令。第一个错误是在subfigure 中使用subfig 的命令,我被困在那里。如果我使用subfigure,我可以访问\subfigure,但不能强制\subgraph工作,当我使用subfig时,我可以在graph中访问\subfloat,但不能在figure中访问,\ref返回1.0a 而不是 1.1 (a)。
subfig 包定义:
\newfloat{graph2}{tbph}{lom}[chapter]
\restylefloat*{graph2}
\floatstyle{plain}
\floatname{grap2}{Graph2}
\captionsetup[graph2]{position=top}
\newcommand{\listofGraphs}{\listof{Graph2}{List of Graphs}}
\newsubfloat[position=bottom,listofformat=subsimple]{graph2}
定义我自己的\subgraph
\newfloat{graph1}{H}{lop}[chapter]
\floatname{graph1}{Graph1}
\newcounter{GraphOne}[graph1]
\def\theGraphOne{\alph{GraphOne}}
\newcommand{\subgraph}[2][]{
\captionof{subGraph}{#1} #2
}
\newfloat{subGraph}{H}{lop}[graph1]
\floatname{subGraph}{}
请帮助我了解\label 和\ref 命令的工作原理(我认为我的解决方案崩溃了,因为\label 在\caption 之前)和/或强制subfig 包按我的意愿工作。
感谢您的任何想法,请善待我的英语。
克劳利
改进:
通过使用 caption 包,我可以创建新计数器 (subGraph) 并在其环境之外使用它。正确引用两个计数器(子图和图)的唯一方法是在 \subgraph 之前使用 \captionof{graph}。
所以,我的新问题是:如何在子图之前执行\captionof{graph} 并在它们下方排版?以及如何强制\ref 显示 1.1-a 而不是 1.1.1
附件:
subfigure 的代码:(返回 <chapter>.<figure> (<subfigure>) 正确。
\begin{figure}
\subfigure[sub-caption]{\includegraphics{fig1}\label{fig:1}}
\caption{main caption}
\end{figure}
\ref{fig:1}
subfig 的代码:(返回 <chapter>.<graph2>-1<subfigure>)不正确。
\begin{graph2}
\subfloat[sub-caption]{\includegraphics{fig1}\label{fig:2}}
\caption{main caption}
\end{graph2}
\ref{fig:2}
我的代码:(返回 <chapter>.<graph1>.<subgraph> 但标题显示相同的“地址”)
\begin{graph1}
\captionof{graph1}{main caption}
\subgraph[sub-caption]{\includegraphics{fig1}\label{fig:3}}
\end{graph1}
\ref{fig:3}
【问题讨论】:
标签: latex label counter caption subfigure