两个并排的图形 - 对齐和大小问题

两个并排的图形 - 对齐和大小问题

有一些方法可以将图形并排放置,例如(subfig不推荐),,subfiguresubcaption。我尝试过,这里是代码和结果:subcaptionboxminipageminipagesubcaption

minipage

\documentclass{article} %Document type
\usepackage{amssymb,amsmath} %Inserting symbols
\usepackage{graphicx} %Inserting graphics
\usepackage{fullpage} 
\usepackage{indentfirst} %Indentation of the first paragraphs
\usepackage{float} %Forcing exact graphic placement - H
\usepackage{chngcntr} %Required package in order to use the macro.
\counterwithin{figure}{section} %Macro: Article class - per-section numbering for figure
\counterwithin{equation}{section} %Macro: Article class - per-section numbering for equation
\counterwithin{table}{section} %Macro: Article class - per-section numbering for tables
\usepackage{physics} %In order to type PDEs easily
\usepackage{bm} %Bold math symbols
\usepackage{booktabs} %Making tables
\usepackage{subcaption} %subfigure and subtable environment
\begin{document}
This is a test document in order to put figures side by side, increase/decrease the sizes of the figures and align horizontally.    
\begin{figure}[H]
\centering
\begin{minipage}{.45\linewidth}
    \includegraphics[width=\linewidth]{./Figures/actual.png}
    \caption{First caption}
    \label{img1}
\end{minipage}
\hspace{.05\linewidth}
\begin{minipage}{.45\linewidth}
    \includegraphics[width=\linewidth]{./Figures/master.png}
    \caption{Second caption}
    \label{img2}
\end{minipage}
\end{figure}
\end{document}

subcaptionbox

\begin{figure}[H]
\centering
\subcaptionbox{Actual Element\label{actual-element}}
{%
    \includegraphics[width=0.48\columnwidth]{./Figures/actual.png}
    \hspace{0.04\columnwidth}
}%
\subcaptionbox{Master Element\label{master-element}}
{%
    \includegraphics[width=0.48\columnwidth]{./Figures/master.png}
    \hspace*{\fill}
}%
\caption{Coordinate Transformation}\label{animals}
\end{figure}

结果是

在此处输入图片描述

可以看出,两者的结果是一样的。

我想让这两个图形更接近且更大。这些图形不应超出\linewidth并且应位于页面中央。

答案1

问题主要是由于 .png 图像周围有额外的宽空间。请检查您的图像或尝试将其上传到您的帖子中。这是您的带有实验性图像的代码:

\documentclass{article} %Document type
\usepackage{amssymb,amsmath} %Inserting symbols
\usepackage{graphicx} %Inserting graphics
\usepackage{fullpage} 
\usepackage{indentfirst} %Indentation of the first paragraphs
\usepackage{float} %Forcing exact graphic placement - H
\usepackage{chngcntr} %Required package in order to use the macro.
\counterwithin{figure}{section} %Macro: Article class - per-section numbering for figure
\counterwithin{equation}{section} %Macro: Article class - per-section numbering for equation
\counterwithin{table}{section} %Macro: Article class - per-section numbering for tables
\usepackage{physics} %In order to type PDEs easily
\usepackage{bm} %Bold math symbols
\usepackage{booktabs} %Making tables
\usepackage{subcaption} %subfigure and subtable environment
\begin{document}
This is a test document in order to put figures side by side, increase/decrease the sizes of the figures and align horizontally.    
\begin{figure}[H]
\centering
\begin{minipage}{.48\linewidth}
    \includegraphics[width=\linewidth]{example-image-A}
    \caption{First caption}
    \label{img1}
\end{minipage}
\hfill
\begin{minipage}{.48\linewidth}
    \includegraphics[width=\linewidth]{example-image-B}
    \caption{Second caption}
    \label{img2}
\end{minipage}
\end{figure}
\end{document}

在此处输入图片描述

以下是从您的帖子中复制的 .png 图像的低质量版本:

在此处输入图片描述

如您所见,图像之间的空间现在变窄了,尺寸也变大了。我在电脑上剪掉了每张图片周围的多余空白。

相关内容