\documentclass[english]{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{fullpage}
\usepackage{babel}
\usepackage[pangram]{blindtext}
\begin{document}
\begin{figure}[htp]
\centering
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{image1}
\caption{\Blindtext[1][1]}
\label{fig:sub1}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\centering
\includegraphics[width=.4\linewidth]{image1}
\caption{\Blindtext[1][2]}
\label{fig:sub2}
\end{subfigure}
\caption{A figure with two subfigures}
\label{fig:test}
\end{figure}
\begin{figure}[htp]
\centering
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=.8\linewidth]{image1}
\captionof{figure}{\Blindtext[1][1]}
\label{fig:test_a1}
\end{minipage}%
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=.8\linewidth]{image1}
\captionof{figure}{\Blindtext[1][2]}
\label{fig:test_a2}
\end{minipage}
\end{figure}
\end{document}
然而,当我将图形并排放置时,通常是因为它们具有相同的尺寸,而我的目的是在它们之间提供某种对比。
如何对齐并排显示的子图?
答案1
您想要的是\begin{subfigure}[t]
或\subcaptionbox
;对于两个并排的独立图形,想法是相同的(subfigure
环境本质上是minipage
)。
\documentclass[english]{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{fullpage}
\usepackage{babel}
\usepackage[pangram]{blindtext}
\begin{document}
\begin{figure}[htp]
\centering
\subcaptionbox{\Blindtext[1][1]\label{fig:sub1}}[.45\textwidth][c]{%
\includegraphics[width=.4\linewidth]{image1}%
}\hfill
\subcaptionbox{\Blindtext[1][2]\label{fig:sub2}}[.45\textwidth][c]{%
\includegraphics[width=.4\linewidth]{image1}%
}
\caption{A figure with two subfigures}\label{fig:test}
\end{figure}
\begin{figure}[htp]
\centering
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=.8\linewidth]{image1}
\caption{\Blindtext[1][1]}\label{fig:test_a1}
\end{minipage}\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=.8\linewidth]{image1}
\caption{\Blindtext[1][2]}
\label{fig:test_a2}
\end{minipage}
\end{figure}
\end{document}