子浮点表

子浮点表

我正在尝试对表格中的图形进行排序(使用子浮点数),并为每个子图添加标签。我的观点是,仅使用子浮点数,文本中的子图被称为图 a、b、... 等等。但我也想按列对它们进行排序,这样它们将被称为 1a、1b、1c、2a、2b、...

有没有办法使用subfig包来实现这一点(通过 subfloat 命令)?或者还有其他包吗?

编辑:解决方案并没有完全满足我的要求...这里有一些精度。我想要两种类型的数字:一种是每个子浮点数都不同,并且有自己的“数字”,另一种是子浮点数必须按列和行排序。

以下是基于第一个答案的示例:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage[lofdepth,listofformat=parens]{subfig}
\usepackage{etoolbox}
\newcounter{subfigRow}
\makeatletter
\newcommand{\newRow}{\refstepcounter{subfigRow}\setcounter{sub\@captype}{0}}
\makeatother
\AtBeginEnvironment{figure}{\setcounter{subfigRow}{1}}
\DeclareCaptionLabelFormat{parens}{(\thesubfigRow#2)}
\DeclareSubrefFormat{parens}{(\thesubfigRow#2)}
\DeclareCaptionListOfFormat{parens}{(\thesubfigRow#2)}

\begin{document}
\listoffigures
\begin{figure}[htb]
\begin{tabular}{lccc}
1 &
\subfloat{\label{one}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{two}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{three}\includegraphics[width=.3\textwidth,height=.25in]{foo}}\\
\newRow
2 &
\subfloat{\label{four}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{five}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{six}\includegraphics[width=.3\textwidth,height=.25in]{foo}}\\
 & (a) & (b) & (c)
\end{tabular}
\caption{A bunch of figures}\label{fig:first}
\end{figure}

\begin{figure}[htb]
\subfloat[A subcaption][A subcaption\label{seven}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{eight}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{nine}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{ten}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{11}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{12}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\caption{Another bunch of figures}\label{fig:second}
\end{figure}
As seen in \subref{one} and \subref{six} of Figure~\ref{fig:first} and
\subref{eight} of Figure~\ref{fig:second}
\end{document}

给出enter image description here

我的观点是在第二种情况下删除该数字。

答案1

这是一种半自动执行的方法。我们为行号定义一个新的计数器;每次添加一行子图时,您都会使用命令\newRow来增加行计数器并重置子图计数器。我还添加了代码来格式化图表列表中的标题和参考资料,以显示整个过程如何协同工作。

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[demo]{graphicx}
\usepackage[lofdepth,listofformat=parens]{subfig}
\usepackage{etoolbox}
\newcounter{subfigRow}
\makeatletter
\newcommand{\newRow}{\refstepcounter{subfigRow}\setcounter{sub\@captype}{0}}
\makeatother
\AtBeginEnvironment{figure}{\setcounter{subfigRow}{1}}
\DeclareCaptionLabelFormat{parens}{(\thesubfigRow#2)}
\DeclareSubrefFormat{parens}{(\thesubfigRow#2)}
\DeclareCaptionListOfFormat{parens}{(\thesubfigRow#2)}

\begin{document}
\listoffigures
\begin{figure}[htb]
\subfloat[A subcaption][A subcaption\label{one}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{two}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{three}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad

\newRow
\subfloat[A subcaption][A subcaption\label{four}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{five}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{six}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\caption{A bunch of figures}\label{fig:first}
\end{figure}

\begin{figure}[htb]
\subfloat[A subcaption][A subcaption\label{seven}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{eight}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{nine}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\newRow
\subfloat[A subcaption][A subcaption\label{ten}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{11}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{12}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\caption{Another bunch of figures}\label{fig:second}
\end{figure}
As seen in \subref{one} and \subref{six} of Figure~\ref{fig:first} and
\subref{eight} of Figure~\ref{fig:second}
\end{document}

output of code

答案2

好的。我只需要调整@Alan Munn 的解决方案,并更改一些subfig包选项。所以这是最终的解决方案:

\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage[lofdepth, subrefformat=subparens]{subfig}
\usepackage{etoolbox}
\newcounter{subfigRow}
\makeatletter
\newcommand{\newRow}{\refstepcounter{subfigRow}\setcounter{sub\@captype}{0}}
\makeatother
\AtBeginEnvironment{figure}{\setcounter{subfigRow}{1}}

\DeclareSubrefFormat{subparens}{(\thesubfigRow#2)}


\begin{document}
\listoffigures
\begin{figure}[htb]
\begin{tabular}{lccc}
1 &
\subfloat{\label{one}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{two}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{three}\includegraphics[width=.3\textwidth,height=.25in]{foo}}\\
\newRow
2 &
\subfloat{\label{four}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{five}\includegraphics[width=.3\textwidth,height=.25in]{foo}} &
\subfloat{\label{six}\includegraphics[width=.3\textwidth,height=.25in]{foo}}\\
 & (a) & (b) & (c)
\end{tabular}
\caption{A bunch of figures}\label{fig:first}
\end{figure}

\begin{figure}[htb]
\subfloat[A subcaption][A subcaption\label{seven}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{eight}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{nine}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{ten}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{11}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\subfloat[A subcaption][A subcaption\label{12}]
    {\includegraphics[width=.3\textwidth,height=.25in]{foo}}
\qquad
\caption{Another bunch of figures}\label{fig:second}
\end{figure}
As seen in \subref*{one} and \subref*{six} of Figure~\ref{fig:first} and
\subref{eight} of Figure~\ref{fig:second}
\end{document}

它给出了enter image description here

感谢您的输入 ;-)

答案3

这就是你想要的东西吗?

screenshot

我已经使用了该subcaption包,并结合了minipages

\documentclass{article}
\usepackage{subcaption}

\begin{document}

\begin{figure}
\begin{minipage}{.5\textwidth}
\begin{subfigure}{\textwidth}
\centering
    \rule{20pt}{30pt}
    \caption{}
    \label{fig:subfig1}
\end{subfigure}\\
\begin{subfigure}{\textwidth}
\centering
    \rule{20pt}{30pt}
    \caption{}
    \label{fig:subfig2}
\end{subfigure}
\caption{}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\begin{subfigure}{\textwidth}
\centering
    \rule{20pt}{30pt}
    \caption{}
    \label{fig:subfig3}
\end{subfigure}\\
\begin{subfigure}{\textwidth}
\centering
    \rule{20pt}{30pt}
    \caption{}
    \label{fig:subfig4}
\end{subfigure}
\caption{}
\end{minipage}
\end{figure}

\ref{fig:subfig1}, \ref{fig:subfig2}, \ref{fig:subfig3}, \ref{fig:subfig4}

\end{document}

相关内容