我有 4 个图,我希望每个图都有一个标题。例如,如果我关注这,它们看起来就像
Fig1. Fig2.
(a) (b)
Fig3. Fig4.
(c) (d)
但我希望他们的标题被组织成
Fig1. Fig3.
(a) (c)
Fig2. Fig4.
(b) (d)
我应该怎么办?
答案1
您可以操作计数器subcaption
来改变编号顺序。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup[subfigure]{labelfont=bf}
\begin{document}
\begin{figure}
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{example-image}
\caption{A subfigure 1}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\setcounter{subfigure}{2} % set next caption to c
\centering
\includegraphics[width=.4\linewidth]{example-image}
\caption{A subfigure 2}
\label{fig:sub2}
\end{subfigure}\\
\bigskip
\begin{subfigure}{.5\textwidth}
\setcounter{subfigure}{1} % set next caption to b
\centering
\includegraphics[width=.4\linewidth]{example-image}
\caption{A subfigure 3}
\label{fig:sub3}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\setcounter{subfigure}{3} % set next caption to d
\centering
\includegraphics[width=.4\linewidth]{example-image}
\caption{A subfigure 4}
\label{fig:sub4}
\end{subfigure}
\caption{ Main caption}\label{fig:main}
\end{figure}
See the figure~\ref{fig:sub2} in the upper left of the Figure~\ref{fig:main}.
\end{document}
更新后续问题:使用子浮点数
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup[figure]{font=sf}
\captionsetup[sub]{labelfont=bf}
\begin{document}
\begin{figure}
\centering
\subfloat[Subfigure 1/4 \label{subfig:s1}]{\includegraphics[width=0.4\textwidth]{example-image}}
\setcounter{subfigure}{2} % set next caption to c
\hfill
\subfloat[Subfigure 3/4 \label{subfig:s2}]{\includegraphics[width=0.4\textwidth]{example-image}}\\
\bigskip
\setcounter{subfigure}{1} % set next caption to b
\subfloat[Subfigure 2/4 \label{subfig:s3}]{\includegraphics[width=0.4\textwidth]{example-image}}
\setcounter{subfigure}{3} % set next caption to d
\hfill
\subfloat[Subfigure 4/4 \label{subfig:s4}]{\includegraphics[width=0.4\textwidth]{example-image}}\\
\caption{ Main caption}\label{fig:main}
\end{figure}
See the figure~\ref{subfig:s2} in the upper left of the Figure~\ref{fig:main}.
\end{document}
答案2
使用我们对minipage
列中的数字进行分组:
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\captionsetup[figure]{font=sf}
\captionsetup[sub]{skip=1ex, belowskip=2ex, labelfont=bf}
\begin{document}
\begin{figure}
\centering
\setkeys{Gin}{width=\linewidth}
\begin{minipage}{0.4\linewidth}
\subfloat[Subfigure 1/4 \label{subfig:s1}]{\includegraphics{example-image-duck}}
\subfloat[Subfigure 2/4 \label{subfig:s2}]{\includegraphics{example-image-duck}}
\end{minipage}
\hfil
\begin{minipage}{0.4\linewidth}
\subfloat[Subfigure 3/4 \label{subfig:s3}]{\includegraphics{example-image-duck}}
\subfloat[Subfigure 4/4 \label{subfig:s4}]{\includegraphics{example-image-duck}}
\end{minipage}
\caption{Main caption}
\label{fig:main}
\end{figure}
See the figure~\ref{subfig:s2} in the bottom left of the Figure~\ref{fig:main}.
\end{document}