下面有一张单张图片,我想为其中的每一张图片添加一个子标题。仅限第一行。我这样做的方式不太好,因为您可以看到每张图片的子标题没有正确对齐。
我希望有人能提出解决方案。下面是我的代码和结果图。为了方便起见,它不需要放在子标题中。
\begin{figure}
\captionsetup[subfigure]{labelformat=empty,position=top}
\centering
\subfloat[$\alpha=0$ \ \ \ $\alpha=1$ \ \ \ \ $\alpha=2$ \ \ \ $\alpha=3$ \ \ \ \ $\alpha=4$ \ \ \ \ $\alpha=5$ \ \ \ \ $\alpha=6$ \ \ \ $\alpha=7$ \ \ \ \ $\alpha=8$ \ \ \ \ $\alpha=9$ \ \ \ $\alpha=10$ \ ]{{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }}
\\
\caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
\label{fig:interpolate-latent}
\end{figure}
编辑:我尝试在图片前添加表格,但无法减少间距。添加负基线跳过无法按我希望的方式工作
\begin{figure}[h]
\captionsetup[subfigure]{labelformat=empty,position=top}
\centering
{\scriptsize
\begin{tabu} to \textwidth { XXXXXXXXXX }
$x_1$ & $x_2$ & $x_3$ & $x_4$ & $x_5$ & $x_6$ & $x_7$ & $x_8$ & $x_9$ & $x_{10}$
\end{tabu}
} \vspace{-2\baselineskip}
\subfloat[]{{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }}
\\
\caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
\label{fig:interpolate-latent}
\end{figure}
答案1
如果图像中的所有子图像都具有相同的宽度并且它们之间的距离也相等,那么这可能会有所帮助:
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\begin{document}
\begin{figure}
\setlength\tabcolsep{0pt}
\begin{tabularx}{\linewidth}{*{11}{>{\centering\arraybackslash\footnotesize $}X<{$}}}
\alpha=0 & \alpha=1 & \alpha=2 & \alpha=3 & \alpha=4 & \alpha=5
& \alpha=6 & \alpha=7 & \alpha=8 & \alpha=9 & \alpha=10 \\
\multicolumn{11}{c}{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }
\end{tabularx}
\caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
\label{fig:interpolate-latent}
\end{figure}
\end{document}
因为我没有您的图像,所以我使用demo
包选项来模拟它graphicx
。所以最后的测试,如果这对您有用我就留给您了。
编辑:从你的评论中我得出结论,你实际上正在寻找这个:
获得方式如下:
\documentclass{article}
\usepackage[margin=20mm]{geometry}% added, i don't now if it is needed
\usepackage[demo]{graphicx}
\usepackage{tabularx}
\usepackage{subfig}
\begin{document}
\begin{figure}
\subfloat[ sub caption text]{% <--- need to be here
\setlength\tabcolsep{0pt}% <--- need to be here
\begin{tabularx}{\linewidth}{*{11}{>{\centering\arraybackslash\footnotesize$}X<{$}}}
\alpha=0 & \alpha=1 & \alpha=2 & \alpha=3 & \alpha=4 & \alpha=5
& \alpha=6 & \alpha=7 & \alpha=8 & \alpha=9 & \alpha=10 \\
\multicolumn{11}{c}{\includegraphics[width=\textwidth]{latent/latent-interpolation.png} }
\end{tabularx}}
\subfloat[ sub caption text]{\includegraphics[width=\textwidth]{latent/latent-interpolation.png}}
\caption{Interpolating between random pairs of latent vectors according to $v = v_1 + (v_2 - v_1) \times \alpha$.}
\label{fig:interpolate-latent}
\end{figure}
\end{document}