sidesubfloat 引用不起作用

sidesubfloat 引用不起作用

我有 tex 文档,为了在子图侧面使用标题索引,我使用sidesubfloat如下命令

\usepackage[demo]{graphicx}  
\usepackage{subfig}
\usepackage{floatrow} 
\usepackage{hyperref} 
\usepackage{color} 


\captionsetup[subfigure]{justification=raggedright,farskip=12pt,captionskip=12pt,position=auto}
\floatsetup[figure]{style=plain,subcapbesideposition=top}
\hypersetup{colorlinks=true,citecolor=blue,linkcolor=blue}



\begin{document}
    \begin{figure}[H]
        \centering
        \sidesubfloat[\label{test1}]{\includegraphics[width=.45\textwidth]{test_figur1.pdf}}\hfill
        \sidesubfloat[\label{test2}]{\includegraphics[width=.45\textwidth]{test_figur2.pdf}}\\\vspace{1cm}
        \sidesubfloat[\label{test3}]{\includegraphics[width=.45\textwidth]{test_figur3.pdf}}\hfill
        \sidesubfloat[\label{test4}]{\includegraphics[width=.45\textwidth]{test_figur4.pdf}}\\
        \label{sidfig}
    \end{figure}
    
    
    
    I want to directly refer the subfigures like this. \ref{test1} or \subref{test2}. But it does not work
    
    
    
\end{document}

我想引用文档中的子图,但它只显示??。但仅使用时,subfloat它工作正常。如何解决这个问题?

答案1

如果您确实不想在左上角放置图形标签,则可以使用子包:

\documentclass[11pt,a4paper]{article}
\usepackage{fontspec}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{hyperref} 
\begin{document}
    \begin{figure}
        \centering
        \subcaptionbox{\label{test1}}{\includegraphics[width=.45\textwidth]{test_figur1.pdf}}
        \subcaptionbox{\label{test2}}{\includegraphics[width=.45\textwidth]{test_figur1.pdf}}
        \subcaptionbox{\label{test3}}{\includegraphics[width=.45\textwidth]{test_figur1.pdf}}
        \subcaptionbox{\label{test4}}{\includegraphics[width=.45\textwidth]{test_figur1.pdf}}
        \label{sidfig}
    \end{figure}

    I want to directly refer the subfigures like this. \ref{test1} or \subref{test2}. But it does not work

\end{document}

PS:我是在lualatex中编译的

相关内容