![subfloat - 将一组子浮点数封装在子浮点数环境中](https://linux22.com/image/393263/subfloat%20-%20%E5%B0%86%E4%B8%80%E7%BB%84%E5%AD%90%E6%B5%AE%E7%82%B9%E6%95%B0%E5%B0%81%E8%A3%85%E5%9C%A8%E5%AD%90%E6%B5%AE%E7%82%B9%E6%95%B0%E7%8E%AF%E5%A2%83%E4%B8%AD.png)
我正在努力寻找将两行数字放入 subfloat 环境中的正确实现。我现在有以下内容:
\documentclass[english]{article}
\usepackage[demo]{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[t]
\centering
\subfloat[ ]{
\includegraphics[width=.32\textwidth]{.png}
\label{fig1}
}
\subfloat[ ]{
\includegraphics[width=.32\textwidth]{.png}
\label{fig:2}
}
\subfloat[ ]{
\includegraphics[width=.32\textwidth]{.png}
\label{fig:3}
}
\subfloat[ ]{
\includegraphics[width=.32\textwidth]{.png}
\label{fig:4}
}
\subfloat[ ]{
\includegraphics[width=.32\textwidth]{.png}
\label{fig:5}
}
\subfloat[ ]{
\includegraphics[width=.32\textwidth]{.png}
\label{fig:6}
}
\caption{}
\label{fig:whatever}
\end{figure}
\end{document}
我希望行上再多一层子标题。我设想以以下格式引用每张图片:图 1.a.1。我也尝试将它们放入子浮点中,但 latex 在堆栈上返回错误。一个限制是,我被迫使用 subfig 包,我无法移动到子图或子标题。
答案1
这基本上是这个答案仅使用\subfloat
(或多或少)这里。
\documentclass[english]{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\DeclareCaptionSubType{subfigure}
\captionsetup[subsubfigure]{labelformat=parens,labelsep=space}
\renewcommand{\thesubfigure}{\alph{subfigure}}
\renewcommand{\thesubsubfigure}{\arabic{subsubfigure}}
\AtBeginDocument{% trial and error
\let\oldsubsubfigure=\subsubfigure
\renewcommand{\subsubfigure}{\expandafter\def\csname @captype\endcsname{subfigure}%
\oldsubsubfigure}%
}
\newsavebox{\subsubfloatbox}% probably overkill
\newcommand{\subsubfloat}[2][\empty]% #1 = caption (optional), #2 = image
{\bgroup
\captionsetup[subsubfigure]{font=footnotesize}%
\savebox\subsubfloatbox{#2}%
\begin{subsubfigure}[t]{\wd\subsubfloatbox}
\usebox\subsubfloatbox
\ifx\empty#1\relax
\stepcounter{subsubfigure}%
\else
\caption{#1}%
\fi
\end{subsubfigure}%
\egroup}
\begin{document}
\begin{figure}[t]
\begin{subfigure}{\columnwidth}
\centering
\subsubfloat[]{%
\includegraphics[width=.32\textwidth]{example-image}%
\label{fig1}%
}\hfil
\subsubfloat[\label{fig:2}]{%
\includegraphics[width=.32\textwidth]{example-image}%
}\hfil
\subsubfloat[\label{fig:3}]{%
\includegraphics[width=.32\textwidth]{example-image}%
}
\caption{}
\end{subfigure}\par
\begin{subfigure}{\columnwidth}
\subsubfloat[\label{fig:4}]{%
\includegraphics[width=.32\textwidth]{example-image}%
}\hfil
\subsubfloat[\label{fig:5}]{%
\includegraphics[width=.32\textwidth]{example-image}%
}\hfil
\subsubfloat[\label{fig:6}]{%
\includegraphics[width=.32\textwidth]{example-image}%
}
\caption{}
\end{subfigure}
\caption{}
\label{fig:whatever}
\end{figure}
\end{document}