[Tex/LaTex] Two figures side by side – Alignment & Size Problem

horizontal alignmentminipagesize;subcaptionsubfloats

There are some ways to put the figures side by side such as subfig (which is not recommended), subfigure, subcaption, subcaptionbox and minipage. I tried minipage and subcaption and here the codes and results:

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}

The result is

enter image description here

As it is seen, both of the results are the same.

I want to make this two figures closer and bigger. These figures should not exceed the \linewidth and should center the page.

Best Answer

The problem is mostly due to the .png images having extra wide space around them. Please check your images or try to upload them in your post. Here is your code with experimental images:

\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}

enter image description here

And here is a low-quality version of your .png images copied from your post:

enter image description here

As you see, the images now have thinner space in-between and are larger. I've cut any extra white space around each one on my computer.