结合 cleveref 和 subcaption 为文本中的图形标题和子图引用提供单独的命令

结合 cleveref 和 subcaption 为文本中的图形标题和子图引用提供单独的命令

**更新

我试图在图片标题和正文中引用多个子图。问题是,当我调用时,\labelcref{...我仍然会在标题中得到图片编号,而我实际上只想要字母。在下面的例子中,我突出显示了我想要阅读的内容“交流电“ 代替 ”1a 至 1c“。

这是我的 MWE:

\documentclass{article}

\usepackage{mwe}
\usepackage{subcaption}
\RequirePackage{xcolor} % Required for specifying custom colors
\usepackage{hyperref}
\hypersetup{pdfpagemode={UseOutlines},
    bookmarksopen=true,
    bookmarksopenlevel=0,
    hypertexnames=true, % reference roman numerals and numeric pages
    colorlinks=true,% Set to false to disable coloring links
    citecolor=blue,% The color of citations
    linktoc=all,
    linkcolor=red,% The color of references to document elements (sections, figures, etc)
    urlcolor=green,% The color of hyperlinks (URLs) 
    pdfstartview={FitV},
    unicode,
    breaklinks=true, % split up links
}
\usepackage{cleveref}
\captionsetup[sub]{labelsep=none, subrefformat=parens} % parentheses around subfigure references
%\crefrangelabelformat{subfigure}{(#3\crefstripprefix{#2}{#1}#4--#5\crefstripprefix{#1}{#2}#6)}

\begin{document}

\section{Section 1}

\begin{figure}[tbp]
    \centering
    \begin{subfigure}{.3\linewidth}
        \includegraphics[width=\linewidth]{image-a}
        \subcaption{\label{fig:1a}}
    \end{subfigure}
    \begin{subfigure}{.3\linewidth}
        \includegraphics[width=\linewidth]{image-b}
        \subcaption{\label{fig:1b}}
    \end{subfigure}
    \begin{subfigure}{.3\linewidth}
    \includegraphics[width=\linewidth]{image-c}
        \subcaption{\label{fig:1c}}
    \end{subfigure}\\[1ex]
        \begin{subfigure}{.3\linewidth}
        \includegraphics[width=\linewidth]{example-image-plain}
        \subcaption{\label{fig:1d}}
    \end{subfigure}
    \begin{subfigure}{.3\linewidth}
        \includegraphics[width=\linewidth]{example-image-golden}
        \subcaption{\label{fig:1e}}
    \end{subfigure}
    \begin{subfigure}{.3\linewidth}
        \includegraphics[width=\linewidth]{example-image-16x10}
        \subcaption{\label{fig:1f}}
    \end{subfigure}
    \caption{The top row \labelcref{fig:1a,fig:1b,fig:1c} are letters of the
    alplhabet.  \subref{fig:1a} `A'.  \subref{fig:1b} `B'.  \subref{fig:1c}
    `C'.  The bottom row \labelcref{fig:1d,fig:1e,fig:1f} are place holders.
    \subref{fig:1d} `Plain'.  \subref{fig:1d} `Golden Ratio'  \subref{fig:1f}
    `16x10'.}
    \label{fig:fig1}
\end{figure}

I can refer to \cref{fig:1a,fig:1b,fig:1c} and \cref{fig:1d,fig:1e,fig:1f}, or
even \cref{fig:1a,fig:1b,fig:1c,fig:1d,fig:1e,fig:1f}.

\end{document}

输出如下:

在此处输入图片描述

有没有办法定义一个自定义\labelcref命令,可以在图形标题而不是文本中调用?

\labelcref{fig:1a,fig:1b,fig:1c}\captionlabelcref{fig:1a,fig:1b,fig:1c}

谢谢!

相关内容