하위 캡션 패키지가 하위 그림에 대한 잘못된 상호 참조를 생성합니다.

하위 캡션 패키지가 하위 그림에 대한 잘못된 상호 참조를 생성합니다.

이미 하위 캡션이 있는 그림을 배치하려고 합니다. 나는 썼다:

\documentclass{article}
\usepackage{subcaption}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{blindtext}
\begin{document}
A reference to \autoref{fig1c}

\begin{figure}[htb]
\centering
\includegraphics[width=0.5\textwidth]{example-image}
\caption{Image description:
\textbf{(a)}~number 1, 
\textbf{(b)}~number 2,
\textbf{(c)}~number 3 and
\textbf{(d)}~number 4
\label{fig1}}
\phantomsubcaption\label{fig1a}
\phantomsubcaption\label{fig1b}
\phantomsubcaption\label{fig1c}
\phantomsubcaption\label{fig1d}
\end{figure}

a reference to \autoref{fig1d}

\end{document}

하지만 수치를 상호 참조하면 해당 수치가 올바르지 않습니다.

여기에 이미지 설명을 입력하세요

어떻게 해결할 수 있나요?

답변1

다음 두 가지를 변경해야 합니다.

  • \phantomsubcaption및 관련 \label지침을 배치하십시오.~ 전에주요 \caption지시문 및 관련 \label명령.

  • 지시어\phantomsubcaption~ 해야 하다TeX 그룹에 스스로 배치됩니다. (패키지 사용설명서 10페이지를 참고하세요 subcaption.)

전체 MWE:

\documentclass{article}
\usepackage{subcaption}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage[colorlinks]{hyperref} % <-- load this package **last**

\begin{document}
A cross-reference to \autoref{fig1c}.

\begin{figure}[htb]
\centering
\includegraphics[width=0.5\textwidth]{example-image}
\begingroup % encase the \phantomsubcaption directives in a TeX group
\phantomsubcaption\label{fig1a}
\phantomsubcaption\label{fig1b}
\phantomsubcaption\label{fig1c}
\phantomsubcaption\label{fig1d}
\endgroup
\caption{%
\textbf{(a)}~number 1, 
\textbf{(b)}~number 2,
\textbf{(c)}~number 3, and
\textbf{(d)}~number 4}
\label{fig1}
\end{figure}

A cross-reference to \autoref{fig1d}.
\end{document}

관련 정보