大家好,大家知道怎样才能使垂直和水平距离均匀(相等)吗?代码如下:
\begin{figure}
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{1_1.jpg}
\label{fig:side:a} %
\end{minipage}
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{1_2.jpg}
\label{fig:side:b}
\end{minipage}
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{1_3.jpg}
\label{fig:side:c}
\end{minipage}
\begin{minipage}[t]{0.5\linewidth}
\centering
\includegraphics[width=\textwidth]{1_4.jpg}
\label{fig:side:d}
\end{minipage}
\end{figure}
提前谢谢您!
答案1
添加minipage
s 和\label
s 不会增加任何内容。如果您的图片具有相同的纵横比,您可以使用以下几个技巧:
\documentclass{article}
\usepackage{graphicx}
\newlength{\twocolgraphwd}
\newenvironment{twocolgraphics}[1][1em]
{%
\centering
\setlength{\twocolgraphwd}{\textwidth}% First step
\addtolength{\twocolgraphwd}{-#1}% remove the space in between
\setlength{\twocolgraphwd}{.5\twocolgraphwd}% divide by two
\setlength{\lineskip}{#1}% set \lineskip to the same gap
\setlength{\spaceskip}{\fill}% fill the space between “words”
\setkeys{Gin}{width=\twocolgraphwd}% all images have the same width
}
{\par}
\begin{document}
\begin{figure}
\begin{twocolgraphics}
\includegraphics{example-image-a}
\includegraphics{example-image-b}
\includegraphics{example-image-c}
\includegraphics{example-image}
\end{twocolgraphics}
\caption{Four figures}
\end{figure}
\begin{figure}
\begin{twocolgraphics}
\includegraphics{example-image-a}
\includegraphics{example-image-b}
\includegraphics{example-image-c}
\end{twocolgraphics}
\caption{Three figures}
\end{figure}
\end{document}
如果你说\begin{twocolgraphics}[2em]
空间将会加倍。
答案2
另一个解决方案tcolorbox
及其raster
库。它以矩阵形式排列框或图像,最初保持(2mm)
列和行之间的距离相同,但您可以使用raster column skip
和进行调整raster row skip
。
\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{figure}
\begin{tcbraster}[enhanced,raster columns=2, size=tight]
\tcbincludegraphics[label=fig:side:a]{example-image-A}
\tcbincludegraphics[label=fig:side:a]{example-image-B}
\tcbincludegraphics[label=fig:side:a]{example-image-C}
\tcbincludegraphics[label=fig:side:a]{example-image}
\end{tcbraster}
\end{figure}
\end{document}
答案3
使用 \hspace* 添加水平空间,不需要居中
\begin{figure}
\begin{minipage}[t]{0.5\linewidth}
\includegraphics[width=\textwidth]{1_1.jpg}
\label{fig:side:a} %
\end{minipage}
\hspace*{\baselineskip}
\begin{minipage}[t]{0.5\linewidth}
\includegraphics[width=\textwidth]{1_2.jpg}
\label{fig:side:b}
\end{minipage}
\begin{minipage}[t]{0.5\linewidth}
\includegraphics[width=\textwidth]{1_3.jpg}
\label{fig:side:c}
\end{minipage}
\hspace*{\baselineskip}
\begin{minipage}[t]{0.5\linewidth}
\includegraphics[width=\textwidth]{1_4.jpg}
\label{fig:side:d}
\end{minipage}
\end{figure}