帶 floatrow 的子引用(無子標題)

帶 floatrow 的子引用(無子標題)

我使用floatrow包而不是創建了子圖subcaption包創建了子圖。後者未載入。

\begin{figure}[htbp]
    \ffigbox[\FBwidth]
    {\begin{subfloatrow}[2]
    \ffigbox[\FBwidth]
    {\caption{Cap1}\label{lab1}}
    {Test1}
    \ffigbox[\FBwidth]
    {\caption{Cap2}\label{lab2}}
    {Test2}
    \end{subfloatrow}}
    {\caption{Cap}
    \label{lab}}
\end{figure}

顯示效果正是我想要的。主標題的標籤為“圖 1:”,副標題的標籤為“(a)”和“(b)”。

但是,我錯過了直接連結到子圖\subref的包宏。subcaptionfloatrow只能\ref{lab1}產生“1a”。前者\subref{lab1}只給出“a”,甚至更好的“(a)”(以匹配labelformat=parens)。

floatrow我可以用 only和captionloaded做類似的事嗎?如果沒有,我如何重新定義\ref巨集以匹配labelformat並從而顯示“1(a)”而不是“1a”?

答案1

您可以透過以下方式做到這一點caption

\documentclass{article}
\usepackage{floatrow}
\usepackage{caption}
\usepackage{graphicx}

\DeclareCaptionSubType[alph]{figure}

\renewcommand\thesubfigure{(\alph{subfigure})}
\captionsetup[subfloat]{labelformat=simple,listformat=simple}

\begin{document}

\listoffigures

\begin{figure}[htbp]
    \ffigbox[\FBwidth]
    {\begin{subfloatrow}[2]
    \ffigbox[\FBwidth]
    {\caption{Caption for subfigure 1}\label{lab1}}
    {\rule{5cm}{1cm}}
    \ffigbox[\FBwidth]
    {\caption{Caption for subfigure 2}\label{lab2}}
    {\rule{5cm}{1cm}}
    \end{subfloatrow}}
    {\caption{General caption}
    \label{lab}}
\end{figure}

As we see in subfigures~\ref{lab1} and~\ref{lab2}, which are subfigures to Figure~\ref{lab}...

\end{document}

在此輸入影像描述

如果您不希望子圖出現在 LoF 中,請更改

\captionsetup[subfloat]{labelformat=simple,listformat=simple}

\captionsetup[subfloat]{labelformat=simple,list=no}

相關內容