
Ich versuche, eine Abbildung zu platzieren, die bereits Untertitel hat. Ich habe geschrieben:
\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}
Aber wenn ich die Zahlen vergleiche, ist ihre Nummer falsch.
Wie kann ich es reparieren?
Antwort1
Sie müssen zwei Änderungen vornehmen:
Platzieren Sie die
\phantomsubcaption
und die zugehörigen\label
AnweisungenVordie Hauptrichtlinie\caption
und die dazugehörige\label
Anweisung.Die
\phantomsubcaption
Richtlinienmussselbst in einer TeX-Gruppe platziert werden. (Siehe S. 10 des Benutzerhandbuchs dessubcaption
Pakets.)
Ein vollständiges 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}