当我放入时,我需要得到图 1.1(a)\Cref{fig:NiceImage1}
。
我必须使用它\Cref{fig:NiceImage}\subref{fig:NiceImage1}
才能获得相同的结果。
\documentclass{scrbook}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\captionsetup{subrefformat=parens}
\usepackage{cleveref}
\setcounter{chapter}{1}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.31\textwidth}
\includegraphics[width=\textwidth]{image1}
\caption{Nice image1}
\label{fig:NiceImage1}
\end{subfigure}
\begin{subfigure}{0.31\textwidth}
\includegraphics[width=\textwidth]{image1}
\caption{Nice image 2}
\label{fig:NiceImage2}
\end{subfigure}
\begin{subfigure}{0.31\textwidth}
\includegraphics[width=\textwidth]{image1}
\caption{Nice image 3}
\label{fig:NiceImage3}
\end{subfigure}
\caption{
\label{fig:NiceImage}
Three images}
\end{figure}
Figure \ref{fig:NiceImage}
Figure \ref{fig:NiceImage} \subref{fig:NiceImage1}
\Cref{fig:NiceImage}
\Cref{fig:NiceImage1}
\end{document}
答案1
将以下几行添加到你的序言中并\Cref{fig:NiceImage1}
显示“图 1.1(a)”
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}
完整代码如下:
\documentclass{scrbook}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
%\captionsetup{subrefformat=parens}
%\subref{fig:NiceImage1} will not work properly...
\usepackage{cleveref}
\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}
\setcounter{chapter}{1}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{0.31\textwidth}
\includegraphics[width=\textwidth]{image1}
\caption{Nice image1}
\label{fig:NiceImage1}
\end{subfigure}
\begin{subfigure}{0.31\textwidth}
\includegraphics[width=\textwidth]{image1}
\caption{Nice image 2}
\label{fig:NiceImage2}
\end{subfigure}
\begin{subfigure}{0.31\textwidth}
\includegraphics[width=\textwidth]{image1}
\caption{Nice image 3}
\label{fig:NiceImage3}
\end{subfigure}
\caption{
\label{fig:NiceImage}
Three images}
\end{figure}
Figure \ref{fig:NiceImage}
Figure \ref{fig:NiceImage} \subref{fig:NiceImage1}
\Cref{fig:NiceImage}
\Cref{fig:NiceImage1}
\end{document}