我使用包subfigure和float来创建我想要创建的图形和表,并且我尝试用自己的计数器和标题创建自己的环境graph (solved there,感谢dmckee)。现在,我想创建\subgraph命令,它将与\subfigure命令完全相同。
我尝试用propreate计数器创建我自己的命令(Assisted here,感谢Alexey)。但是使用\ref命令会出现问题。对\subfigure的引用返回2.1(a),而对\subgraph的引用返回1。
当我试图了解如何解决这个问题时,我阅读了subfig手册,其中我找到了一个示例\newsubfloat命令。第一个错误是在subfigure中使用subfigure的命令,如果我使用subfigure,我可以访问\subfigure,但不能强制\subgraph工作。当我使用subfig时,我可以在graph中访问\subfloat,但不能在figure中访问\subfloat;\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)并在其环境之外使用它。正确引用计数器(子图和图)的唯一方法是在\captionof{graph}之前使用\subgraph。
因此,我的新问题是:如何在子图和排版之前执行\captionof{graph}?以及如何强制\ref显示1.1a而不是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>,但标题显示相同的"adress")
\begin{graph1}
\captionof{graph1}{main caption}
\subgraph[sub-caption]{\includegraphics{fig1}\label{fig:3}}
\end{graph1}
\ref{fig:3}发布于 2010-01-08 08:26:14
我认为您的subfig解决方案应该可以工作(无论如何,subfigure是不推荐的)。错误引用的问题可能与您的using \label incorrectly有关。必须在\label命令之后使用\caption命令,或者作为其中的一部分:
\begin{figure}
\caption{A Figure}
\label{fig}
\end{figure}或
\begin{figure}
\caption{A Figure%
\label{fig}}
\end{figure}编辑:以下“为我工作”。就像我说的,\label是在\caption之后
\documentclass{report}
\usepackage{float}
\usepackage{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}
\begin{document}
\chapter{Test}
\section{Test s}
\begin{graph2}
\subfloat[sub-caption]{\fbox{Fig 1}}
\caption{main caption}
\label{fig:1}
\end{graph2}
\begin{graph2}
\subfloat[sub-caption]{\fbox{Fig 2}}
\caption{main caption}
\label{fig:2}
\end{graph2}
Graph~\ref{fig:1} is the first graph, and~\ref{fig:2} is the second.
\end{document}这就产生了:
Graph 1.1 is the first graph, and 1.2 is the second.发布于 2010-01-08 09:17:25
我现在不能详细说明,但是您想要使用\ right计数器而不是加载项计数器。
https://stackoverflow.com/questions/2025338
复制相似问题