我有两张图片,我将\usepackage{subcaption}
它们放在一起。输出可能如下所示。
上图中的问题在于,很难阅读每张图片的描述。我的问题是,有没有办法减少每个子标题的宽度?
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{blindtext}
\begin{document}
\begin{figure}[H]
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=6cm]{rose.png}
\caption{\blindtext}
\label{fig:subim1}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
\includegraphics[width=0.9\linewidth, height=6cm]{rose.png}
\caption{\blindtext}
\label{fig:subim2}
\end{subfigure}
\caption{Caption for this figure with two images}
\label{fig:image2}
\end{figure}
\end{document}
答案1
有两种方法可供选择。第一种是让整个子图变小一点,这也会使图变小一点。如果不想这样,只需将标题宽度调小一点。无论你选择哪种方式,如果不将图片居中,它看起来都会有点奇怪。
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{blindtext}
\begin{document}
\begin{figure}
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width=0.9\linewidth,
height=5cm]{example-image-a}
\caption{\blindtext}
\end{subfigure}\hfill
\begin{subfigure}{0.45\textwidth}
\centering
\includegraphics[width=0.9\linewidth,
height=5cm]{example-image-b}
\caption{\blindtext}
\end{subfigure}
\caption{Caption for this figure with two images}
\end{figure}
\begin{figure}
\begin{subfigure}{0.5\textwidth}%
\centering\captionsetup{width=.8\linewidth}%
\includegraphics[width=0.9\linewidth,height=5cm]{example-image-a}%
\caption{\blindtext}
\end{subfigure}% Ensure no space and avoid warning
\begin{subfigure}{0.5\textwidth}%
\centering\captionsetup{width=.8\linewidth}%
\includegraphics[width=0.9\linewidth,height=5cm]{example-image-b}%
\caption{\blindtext}
\end{subfigure}
\caption{Caption for this figure with two images}
\end{figure}
\end{document}