
pgfplots를 사용하여 그룹 플롯을 만들었습니다. 각 플롯을 참조하기 위해 각 플롯의 노드 내에 하위 캡션을 추가했습니다.
\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}[h]
\begin{tikzpicture}
\begin{groupplot}[group style={group size=1 by 2}]
\nextgroupplot
\node [text width=1em,anchor=north west] at (rel axis cs: 0,1) {\captionof{subfigure}{\label{fig:a}}};
\addplot plot coordinates {(0,0) (1,1) (2,2) (3,3)};
\nextgroupplot
\node [text width=1em,anchor=north west] at (rel axis cs: 0,1) {\captionof{subfigure}{\label{fig:b}}};
\addplot plot coordinates {(0,0) (1,1) (2,4) (3,9)};
\end{groupplot}
\end{tikzpicture}
\caption{Figure}
\end{figure}
Figure \ref{fig:a} and \ref{fig:b}?!?
\end{document}
문제는 카운터가 잘못되었다는 것입니다. 하위 그림 1a는 0a로 참조됩니다. 내 전체 문서에서 동일한 동작이 발생합니다. 예를 들어 4b는 3b를 얻습니다.
답변1
\subcaption{\label{fig:a}}
및 를 사용하여 \subcaption{\label{fig:b}}
하위 캡션을 설정하세요.
암호:
\documentclass{article}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}% <- added, current version is 1.13
\usepgfplotslibrary{groupplots}
\begin{document}
\begin{figure}[htb]
\begin{tikzpicture}
\begin{groupplot}[group style={group size=1 by 2}]
\nextgroupplot
\node [text width=1em,anchor=north west] at (rel axis cs: 0,1)
{\subcaption{\label{fig:a}}};%<- changed
\addplot plot coordinates {(0,0) (1,1) (2,2) (3,3)};
\nextgroupplot
\node [text width=1em,anchor=north west] at (rel axis cs: 0,1)
{\subcaption{\label{fig:b}}};%<- changed
\addplot plot coordinates {(0,0) (1,1) (2,4) (3,9)};
\end{groupplot}
\end{tikzpicture}
\caption{Figure}
\end{figure}
Figure \ref{fig:a} and \ref{fig:b}?!?
\end{document}
값 을 설정하는 것이 유용하다는 점에 유의하십시오 compat
.