如何让两张图片并排显示在横向页面上?
(编辑:我已在下面回答了此问答风格。欢迎提出其他方法或改进建议)
答案1
不清楚你的问题是什么。你的代码片段插入到一些测试文档中,例如:
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{caption, subcaption}
\usepackage{pdflscape}
\usepackage{graphicx}
\begin{document}
% your code fragment
\end{document}
运行良好,并且具有当今推荐的形式。当然,你可以通过使用关键字使其更短一点,Gin
就像我在以下 MWE 中所做的那样:
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{caption, subcaption}
\usepackage{pdflscape}
\usepackage{graphicx}
\begin{document}
\begin{landscape}
\begin{figure}[p]
\setkeys{Gin}{width=\linewidth} % <---
\centering
\begin{subfigure}[t]{0.45\linewidth}
\includegraphics{example-image-duck}
\caption{Caption 1}
\label{fig:subim1}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.45\linewidth}
\includegraphics{example-image-duck}
\caption{Caption 2}
\label{fig:subim2}
\end{subfigure}
\caption{Caption for this figure with two images: by use of \texttt{subfigure} (recommended)}
\label{fig:image2}
\end{figure}
\begin{figure}[p]
\setkeys{Gin}{width=0.45\linewidth} % <---
\centering
\subfloat[Caption 1 \label{fig:subim1}]{\includegraphics{example-image-duck}}
\hfil
\subfloat[Caption 2 \label{fig:subim2}]{\includegraphics{example-image-duck}}
\caption{Caption for this figure with two images: by use of \texttt{subfloat} (less recommended)}
\label{fig:image2}
\end{figure}
\end{landscape}
\end{document}
除了上述解决方案之外,还有其他解决方案。请参阅@Bernard回答(+1)。
答案2
subfloatrow
使用包中的环境很容易floatrow
:
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{caption, subcaption}
\usepackage{lscape}
\usepackage{graphicx}
\usepackage{floatrow}
\begin{document}
\begin{landscape}
\floatsetup{captionskip=2ex}
\begin{figure}[!htb]
\ffigbox[\textheight]{%
\begin{subfloatrow}[2]
\centering
\ffigbox[\FBwidth]{\caption{Ils se lèvent à la pointe du jour (1950)}\label{T1}}{\includegraphics[scale=0.3]{PointeduJour}}
\qquad
\ffigbox[\FBwidth]{\caption{La Dormeuse (1937)}\label{T2}}{\includegraphics[scale=1.37]{LaDormeuse}}
\end{subfloatrow}%
}{\caption{Two Paintings by Toyen}\label{Toyen}}
\end{figure}
\end{landscape}
\end{document}