2

パッケージsubfigureを使用floatして、作成したい図と表を作成しています。graph独自のカウンターとキャプションを使用して独自の環境を作成しようとしています ( dmckee のおかげで解決されました)。\subgraph次に、コマンドとまったく同じことを行うコマンドを作成したいと思います\subfigure

適切なカウンターを使用して独自のコマンドを作成しようとしました(ここで支援、Alexeyに感謝します)。しかし、\refコマンドを使用すると問題が発生します。への参照は2.1(a)\subfigureを返しますが、への参照は1を返します。\subgraph

これを解決する方法を見つけようとしたときにsubfig、マニュアルを読みました。そこでは、\newsubfloatコマンドと例を見つけました。最初のエラーはsubfigのコマンドの使用中にsubfigureあり、そこで行き詰まりました。私が使用すると、subfigureアクセスできます\subfigure強制的\subgraphに動作することはsubfigできません.\subfloatgraphfigure\ref

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}beforeを使用すること\subgraphです。

だから、私の新しい質問は次\captionof{graph}のとおりです。サブグラフの前に実行し、それらの下にタイプセットする方法は? \ref1.1.1 の代わりに 1.1-aを強制的に表示する方法

付属品:

コードsubfigure: ( を返します<chapter><figure>( <subfigure>) 正しい。

\begin{figure}
\subfigure[sub-caption]{\includegraphics{fig1}\label{fig:1}}
\caption{main caption}
\end{figure}
\ref{fig:1}

Code for subfig: (Returns <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}
4

2 に答える 2

2

あなたのsubfigソリューションはうまくいくはずです(subfigureとにかく非推奨です)。参照が間違っているという問題は、を正しく使用し\labelていないことに関係している可能性があります。の後に、またはその一部として\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-08T08:26:14.483 に答える
0

今は詳しく説明できませんが、\addtocounterの代わりに\refstepcounterを使用したいと考えています。

于 2010-01-08T09:17:25.457 に答える