如何在两个并排的图形之间留出水平空间,然后自动将图片缩放到新的宽度?

如何在两个并排的图形之间留出水平空间,然后自动将图片缩放到新的宽度?

我一直在研究如何将书中的图和标题并排放置,但一直没能找到在两个图之间留出水平空间的方法。自从我开始使用 PDF 图像以来,一直存在一些问题,所以我只是想提一下以防万一。

到目前为止,我一直在使用 minipage 解决方案来管理这个问题,但我不知道该怎么做。任何帮助或建议都将不胜感激。

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[paperwidth=6in, paperheight=9in, margin=0.9in, showframe]{geometry}
\usepackage{lipsum}
\begin{document}

\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=1\linewidth]{camellia}
\captionof{figure}{an evergreen eastern Asian shrub related to the tea plant, grown for its showy flowers and shiny leaves.}
\label{camellia}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=1\linewidth]{rose}
\captionof{figure}{a prickly bush or shrub that typically bears red, pink, yellow, or white fragrant flowers, native to north temperate regions. Numerous hybrids and cultivars have been developed and are widely grown as ornamentals.}
\label{rose}
\end{minipage}
\end{figure}

\lipsum
\end{document}

图像:输出

我想要获得的是:

在此处输入图片描述

我没有在标题中提到这一点,但我还想让标题相互内联。并且图像也位于同一行,如下所示:

在此处输入图片描述

答案1

在此处输入图片描述

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[paperwidth=6in, paperheight=9in, margin=0.9in, showframe]{geometry}
\usepackage{lipsum}
\begin{document}

\begin{figure}
\centering
\begin{minipage}{.4\textwidth}
\centering
\includegraphics[width=1\linewidth]{example-image}
\end{minipage}\qquad
\begin{minipage}{.4\textwidth}
\centering
\includegraphics[width=1\linewidth]{example-image-golden-upright}
\end{minipage}

\bigskip

\begin{minipage}[t]{.4\textwidth}
\centering

\caption{an evergreen eastern Asian shrub related to the tea plant, grown for its showy flowers and shiny leaves.}
\label{camellia}
\end{minipage}\qquad
\begin{minipage}[t]{.4\textwidth}
\centering
\caption{a prickly bush or shrub that typically bears red, pink, yellow, or white fragrant flowers, native to north temperate regions. Numerous hybrids and cultivars have been developed and are widely grown as ornamentals.}
\label{rose}
\end{minipage}
\end{figure}

\lipsum
\end{document}

答案2

只需为小页面保留所需的空间;就\dimexpr可以很容易地修复图像之间的空间(这里为 2 em)。

请注意,您不需要\captionof。使用\begin{minipage}[t]可确保与图片底部对齐。

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage[paperwidth=6in, paperheight=9in, margin=0.9in, showframe]{geometry}
\usepackage{lipsum}
\begin{document}

\begin{figure}
\centering
\begin{minipage}[t]{\dimexpr.5\textwidth-1em}
\centering
\includegraphics[width=\textwidth]{example-image-9x16}

\caption{an evergreen eastern Asian shrub related to the tea plant,
grown for its showy flowers and shiny leaves.}\label{camellia}
\end{minipage}\hfill
\begin{minipage}[t]{\dimexpr.5\textwidth-1em}
\centering
\includegraphics[width=\textwidth]{duck}

\caption{a prickly bush or shrub that typically bears red, 
pink, yellow, or white fragrant flowers, native to north 
temperate regions. Numerous hybrids and cultivars have been 
developed and are widely grown as ornamentals.}\label{rose}
\end{minipage}
\end{figure}

\lipsum
\end{document}

在此处输入图片描述

相关内容