子浮动图形下方的标题未与相应图像对齐。有什么解决办法吗?
\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{subfig}
\begin{document}
\lipsum[1]
\begin{figure}[h]%
\captionsetup{width=0.8\textwidth}
\centering
\subfloat[Subcaption 1]{{\label{fig_1}\includegraphics[width=3cm,keepaspectratio]{example-image-a} }} %
\quad
\subfloat[Subcaption 2]{{\label{fig_2}\includegraphics[width=3cm,keepaspectratio]{example-image-b} }}
\end{figure}
\lipsum[1]
\end{document}
答案1
subfigure
包提供的环境subcaption
做得更好。
可以只设置字幕,\captionsetup[sub]{<options>}
不受主角的字幕设置干扰。
\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{subcaption} % added <<<<<<<<<<<
\begin{document}
\lipsum[1]
\noindent \begin{figure}[h]%
\captionsetup{width=0.8\textwidth}
\captionsetup[sub]{font={sf,it}}
\centering
\begin{subfigure}[c]{3cm}
\includegraphics[width=3cm,keepaspectratio]{example-image-a}
\caption{Subcaption 1} \label{fig_1}
\end{subfigure}
\quad
\begin{subfigure}[c]{3cm}
\includegraphics[width=3cm,keepaspectratio]{example-image-b}
\caption{Subcaption 2} \label{fig_2}
\end{subfigure}
\caption{\lipsum[4]}
\end{figure}
See figure \ref{fig_1}.
\lipsum[1]
\end{document}