引用一组不起作用的子图

引用一组不起作用的子图

尝试引用整个图形会导致 ?? 但引用每个单独的子图可以正常工作。我该如何解决这个问题?我希望在下面的示例中引用图 1。 示例图像

梅威瑟:

\documentclass[12pt, a4paper]{article}
\usepackage{pgfplots}
\usepackage{psfrag}
\usepackage{subfig}
\pgfplotsset{compat=1.5}
\usepackage{cleveref}
\begin{document} 
\begin{figure}[hb]
    \centering
    \begin{tabular}{ccc}
        \multicolumn{3}{c}{\begin{tikzpicture}
            \begin{axis}[
            at={(-3,-0.5)},
            hide axis,
            scale only axis,
            height=0pt,
            width=15cm,
            colormap/jet,
            colorbar horizontal,
            colorbar style={ylabel=dB},
            point meta min=-20,
            point meta max=0,
            ]
            \end{axis}
            \end{tikzpicture}}\\
        \subfloat[][]{\label{fig:sub-a}\includegraphics[width=5cm]{example-image-a}}
        &
        \subfloat[][]{\label{fig:sub-b}\includegraphics[width=5cm]{example-image-b}}
        &
        \subfloat[][]{\label{fig:sub-c}\includegraphics[width=5cm]{example-image-c}}\\
    \end{tabular}
    \label{fig:subs}
    \caption{}
\end{figure}
\Cref{fig:subs} isn't working but \cref{fig:sub-a,fig:sub-b,fig:sub-c} is.
\end{document}

答案1

放置\label{fig:subs}\caption{}即可解决问题。

\documentclass[12pt, a4paper]{article}
\usepackage{pgfplots}
\usepackage{psfrag}
\usepackage{subfig}
\pgfplotsset{compat=1.5}
\usepackage{cleveref}
\begin{document} 
\begin{figure}[hb]
    \centering
    \begin{tabular}{ccc}
        \multicolumn{3}{c}{\begin{tikzpicture}
            \begin{axis}[
            at={(-3,-0.5)},
            hide axis,
            scale only axis,
            height=0pt,
            width=15cm,
            colormap/jet,
            colorbar horizontal,
            colorbar style={ylabel=dB},
            point meta min=-20,
            point meta max=0,
            ]
            \end{axis}
            \end{tikzpicture}}\\
        \subfloat[][]{\label{fig:sub-a}\includegraphics[width=5cm]{example-image-a}}
        &
        \subfloat[][]{\label{fig:sub-b}\includegraphics[width=5cm]{example-image-b}}
        &
        \subfloat[][]{\label{fig:sub-c}\includegraphics[width=5cm]{example-image-c}}\\
    \end{tabular}
    \caption{}
    \label{fig:subs}
\end{figure}
\Cref{fig:subs} isn't working but \cref{fig:sub-a,fig:sub-b,fig:sub-c} is.
\end{document}

相关内容