我确信我见过这个问题,但今天我没有找到它。我有一个包含之前制作的图形的文档。该图形已经有子图和(A),(二).. 标记。考虑到只有一个图像,我该如何标记这些子图?
假设下面的 MWE 中给出的示例图像是这样的:
\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{subcaption}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{\linewidth}
\centering
\includegraphics[width=0.8\linewidth]{example-image-a}
\label{image-a}
\end{subfigure}
\begin{subfigure}{0\linewidth}
\label{image-b}
\end{subfigure}
\begin{subfigure}{0\linewidth}
\label{image-c}
\end{subfigure}
\begin{subfigure}{0\linewidth}
\label{image-d}
\end{subfigure}
\caption{Example}
\label{figure-1}
\end{figure}
Te figure \ref{figure-1} is has the subfigures
\ref{image-a}, \ref{image-b}, \ref{image-c} and \ref{image-d}
\end{document}
答案1
要使\label
工作,您需要\caption
对每个 都使用subfigure
。这将至少生成子图的字母。但是可以用 和 进行更改\DeclareCaptionLabelFormat
,\captionsetup
这样空的\caption{}
就不会生成任何内容。此外,应删除一些虚假元素以使图形正确居中。
\documentclass[12pt,a4paper]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{subcaption}
\usepackage{graphicx}
% new empty caption label format
\DeclareCaptionLabelFormat{nocaption}{}
\begin{document}
\hrule % to check, if properly centered
\begin{figure}[h]% parameter just for testing
% enable the empty caption label format locally
\captionsetup[subfigure]{labelformat=nocaption}
\centering
\includegraphics[width=0.8\linewidth]{example-image-a}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-a}
\end{subfigure}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-b}
\end{subfigure}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-c}
\end{subfigure}% <----- get rid of space, for proper centering
\begin{subfigure}{0\linewidth}
\caption{}\label{image-d}
\end{subfigure}
\caption{Example}
\label{figure-1}
\end{figure}
Te figure \ref{figure-1} is has the subfigures
\ref{image-a}, \ref{image-b}, \ref{image-c} and \ref{image-d}
\end{document}