目前,我已经
\usepackage{subfig}
\usepackage{tabularx}
\usepackage{multirow}
\begin{figure*}
\def\tabularxcolumn#1{m{#1}}
\begin{tabularx}{\linewidth}{@{}ccc@{}}
%
\subfloat[caption]{\includegraphics[width=.3\linewidth]{a}}
\subfloat[caption]{\includegraphics[width=.3\linewidth]{b}}
\begin{tabular}{c}
\subfloat[caption]{\includegraphics[width=.25\linewidth]{c}} \\
\subfloat[caption]{\includegraphics[width=.25\linewidth]{d}}
\end{tabular}
\\
\subfloat[caption]{\includegraphics[width=.3\linewidth]{e}}
\subfloat[caption]{\includegraphics[width=.3\linewidth]{f}}
\subfloat[caption]{\includegraphics[width=.3\linewidth]{g}}
\\
\subfloat[caption]{\includegraphics[width=.3\linewidth]{h}}
\subfloat[caption]{\includegraphics[width=.3\linewidth]{i}}
\subfloat[caption]{\includegraphics[width=.3\linewidth]{j}}
\end{tabularx}
\caption{A selection of the slides made during the user study}\label{slides}
\end{figure*}
其中 c 和 d 与 a 和 b 不对齐,导致整行更高。
我首先开始关注如何将子图放在多行中,图像按我预期的方式排列。但标题标签按列而不是行排列,如下所示
a d g/h
b e i
c f j
我尝试使用多行,但它遇到了类似的问题
\begin{tabular}{ccc}
\multirow{ 2}{*}{\subfloat[caption]{\includegraphics[width=.3\linewidth]{a}}}&
\multirow{ 2}{*}{\subfloat[caption]{\includegraphics[width=.3\linewidth]{b}} }&
\subfloat[caption]{\includegraphics[width=.25\linewidth]{c}} \\
&&\subfloat[caption]{\includegraphics[width=.25\linewidth]{d}}
\end{tabular}
有没有办法将子浮点数 c 和 d 上移以匹配 a 和 b?
答案1
为了使图像 c 和 d 对齐,您需要将选项 [b] 添加到嵌套表中,例如:
\begin{tabular}[b]{@{}c@{}}
除此之外,你的使用tabularx
也是错误的。如果你使用它,那么你也应该使用它的列类型X
。图像也应该排列在列之间:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\usepackage{tabularx}
\usepackage{multirow}
\begin{document}
\begin{figure*}
\begin{tabularx}{\linewidth}{@{}*{3}{>{\centering\arraybackslash}X}@{}}
%
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image-a}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image-b}}
&
\begin{tabular}[b]{@{}c@{}}
\subfloat[caption]{\includegraphics[width=.8\linewidth,height=1cm]{example-image}} \\
\subfloat[caption]{\includegraphics[width=.8\linewidth,height=1cm]{example-image}}
\end{tabular}
\\
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
\\
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
&
\subfloat[caption]{\includegraphics[width=\linewidth]{example-image}}
\end{tabularx}
\caption{A selection of the slides made during the user study}\label{slides}
\end{figure*}
\end{document}
答案2
你不需要任何外部tabular
(甚至更少tabularx
)。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[htp]
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-a}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-b}}\hfill
\begin{minipage}[b]{.3\textwidth}
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}} \\
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}}
\end{minipage}
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}
\caption{A selection of the slides made during the user study}\label{slides}
\end{figure}
\end{document}
诀窍是使用合适的宽度,即略小于文本宽度的 1/3。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}
\begin{figure}[htp]
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-a}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image-b}}\hfill
\begin{minipage}[b]{.3\textwidth}
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}} \\
\subfloat[caption]{\includegraphics[width=\textwidth,height=1cm]{example-image}}
\end{minipage}
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subfloat[caption]{\includegraphics[width=.3\textwidth]{example-image}}
\caption{A selection of the slides made during the user study}\label{slides}
\end{figure}
\end{document}
如果您没有subfig
因为特定原因而受限于不兼容的文档类caption
,我建议caption
与一起使用subcaption
。
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subcaption}
\begin{document}
\begin{figure}[htp]
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image-a}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image-b}}\hfill
\begin{minipage}[b]{.3\textwidth}
\subcaptionbox{caption}{\includegraphics[width=\textwidth,height=1cm]{example-image}}\\[1ex]
\subcaptionbox{caption}{\includegraphics[width=\textwidth,height=1cm]{example-image}}
\end{minipage}
\medskip
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}
\medskip
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}\hfill
\subcaptionbox{caption}{\includegraphics[width=.3\textwidth]{example-image}}
\caption{A selection of the slides made during the user study}\label{slides}
\end{figure}
\end{document}